我的表有 10 条记录,mysql_num_rows 表示 mysql 资源中有 10 行,在 phpMyAdmin 中我可以看到 10 行,但是当调用 mysql_fetch_array 时,前两次正常工作,然后最后 8 次返回 FALSE。
为什么?
$query = "SELECT * FROM building_types";
$building_types = mysql_query($query) or die( mysql_error() );// works
echo mysql_num_rows($building_types); // prints 10
$num_rows = mysql_num_rows($building_types);
for ( $i = 0 ; $i < $num_rows ;$i++ )
{
echo"hi1"; // this is printed 10 times
$building_type = mysql_fetch_array($building_types);
echo $building_type; // prints Array 2 times not 10 times ...
if ( $building_type === FALSE ) echo"hi2"; //this is printed the last 8 times ...
谢谢,