foreach(mysql_fetch_array($result) as $key=>$row){
print_r($row);
}
这样只能遍历输出最后一条记录
下面这样就能全部遍历,是不是说明数据库返回的数组与平常的不同?
while($row=mysql_fetch_array($result))
{
$rows[] = $row;
}
foreach($rows as $k => $v)
{
foreach($v as $vv){
echo $vv;
}
mysql_fetch_array
?foreach
------解决方案--------------------
while 可以循环读取数据库中的记录,而foreach 只能遍历已存在的数组或者对象。