为何mysql_fetch_array/assoc + foreach只能遍历一条记录

WBOY
Release: 2016-06-13 12:34:16
Original
1148 people have browsed it

为什么mysql_fetch_array/assoc + foreach只能遍历一条记录

foreach(mysql_fetch_array($result) as $key=>$row){<br />
							<br />
					 	print_r($row);<br />
									<br />
				} 
Copy after login


这样只能遍历输出最后一条记录

下面这样就能全部遍历,是不是说明数据库返回的数组与平常的不同?

while($row=mysql_fetch_array($result)) <br />
{ <br />
       $rows[]  = $row; <br />
} <br />
<br />
foreach($rows as $k => $v) <br />
{ <br />
   foreach($v as $vv){<br />
     echo $vv;<br />
   }
Copy after login

mysql_fetch_array ?foreach
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!