ok I already know the topic of the while and all that I know how to get everything from a table, Now what I want is the following: I have two tables one " friends " another " main " in this case I do not want to print anything, the table friends contains the id of the users who are example friends "of" and "for" the other table only contains a field id_user without counting the auto increment there is an action that saves the id of the users in the "main" table what necito is to make a query that tells me how many id there is in the "main" table that are my friends example of the code for better understanding
my query
<?php
include"conexion.php";
$yo=$_SESSION["id"];
//hago una consulta en la tabla amigos donde de sea mi id
$ami=mysqli_query($conexion,"SELECT * FROM amigos WHERE de='$yo' ");
while ( $obtener_amigos_id=mysqli_fetch_assoc($ami)){
//aqui saco todos los id que son mis amigos, nose si esta consulta while
este correcta a sinceridad
$id_de_amigos=$obtener_amigos_id["para"];
}
//otra consulta en la tabla principal para saver cuantos amigos mios hay aqui
//tengo 9 amigos y en esta tabla hay 5 amigos mios
$mostrar_cantidad_amigos= mysqli_query($conexion,"SELECT * FROM principal
WHERE id_user='".$id_de_amigos["para"]."' ");
$cantida_id_amigos=mysqli_num_rows($mostrar_id_amigos);
//solo me arroja uno y tengo 9 amigos, de esos 9 el resultado esperado es 5
echo $cantida_id_amigos;
?>
I would appreciate a help because I am not receiving the expected result