I’m making a PHP to check for the friends ID in a friends relation table, then returns the info of the friends.
The problem is, the first loop loops 2 times, and that’s right, when I check for the value of the count of the second loop, I find it equals to 4, how can this happen and the second table got 4 rows?
Here’s the code:
while ($rowres = mysql_fetch_array($listres))
{
if ($_GET["ID"] == $rowres["ID"])
{
while ($row = mysql_fetch_array($result))
{
$count++;
if ($rowres["FID"] == $row["ID"])
{
}
}
}
}
the inner loop will loop through result only one loop, because after it loops to the last element of $result pointer of result will be point after last element, the easiest way here will be probably reset pointer to the top:
please note: mysql extension is DEPRECATED and will be removed in the future. Instead use mysqli or PDO