When you define a variable as the return of a mysql_query() like so: $variable = mysql_query($query); And you are wishing to get MULTIPLE returns (loops) of the mysql_fetch_array statement (a.k.a. multiple rows), you CANNOT define it like so. while ($variable = mysql_fetch_array($variable)) After the first execution of the loop, the content of the $variable variable will be unable to present a valid mysql resource for mysql_fetch_array to reuse after the while statement proceeds with another execution (because there are multiple rows). There will eventually be an issue with the mysql_fetch_array() call when attempting to present mysql_fetch_array() with a valid mysql resource (as returned from the mysql_query call) because it will be presenting an array return of mysql_fetch_array from the first execution of the while statement.