Can anybody tell me why this function is not working correctly.
function user_list()
{
$result = mysql_query("SELECT DISTINCT user FROM users" ,$db);
if ($myrow = mysql_fetch_array($result))
{do {printf ("<option value=\"%s \">%s</option>\n", $myrow['user'], $myrow['user']); }
while ($myrow = mysql_fetch_array($result));}
else { printf ("<option value=\"\">No Records</option>\n"); }
}
user_list();
When I run the function using
user_list();
it takes the else statement as if there are no records in the DB. But if i type out
if ($myrow = mysql_fetch_array($result))
{do {printf ("<option value=\"%s \">%s</option>\n", $myrow['user'], $myrow['user']); }
while ($myrow = mysql_fetch_array($result));}
else { printf ("<option value=\"\">No Records</option>\n"); }
everytime its needed it displays all of the users in the DB.
Any Ideas???