Heim >Datenbank >MySQL-Tutorial >多次执行mysql_fetch_array()的指针归位问题探讨_MySQL

多次执行mysql_fetch_array()的指针归位问题探讨_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:23:431192Durchsuche

bitsCN.com 有时候在读取数据库之后,针对同一结果集,在同一个页面上输出的时候可能会碰到多次输出,也就是多次执行mysql_fetch_array(),在第二次执行的时候,如果不加处理,就不会输出任何内容,这种情况下只需要对循环指针进行复位即可。
第一次执行:

while($row=mysql_fetch_array($result)) {
echo $row['name']."
";
}

第二次执行:

mysql_data_seek($result,0);//指针复位
while($row=mysql_fetch_array($result)) {
echo $row['name']."
";
}
bitsCN.com

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn