www.5213.net > php whilE循环和ForEACh循环 mysql_FEtCh_ArrAy()

php whilE循环和ForEACh循环 mysql_FEtCh_ArrAy()

while循环和foreach循环在mysql_fetch_array()的用法: while举例如下: foreach循环举例如下: $rows = mysql_fetch_all($result); foreach($rows as $row){ printf ("ID: %s Name: %s", $rows[0], $rows[1]); }

用while循环例如: $res = mysql_query("select id,name,description,price,pic_url1 from ebf_products"); while($pp = mysql_fetch_array($res,MYSQL_ASSOC) or false){ $list[] = $pp; }

mysql_fetch_array() 函数返回一行记录的一维数组,并把指针移动到下一行,所以它的运行结果本身就是一维数组: 字段和数字索引同时存在: Array ( [0] => 1 [id] => 1 [1] => 文章标题 [title] => 文章标题 }mysql_fetch_array()相当于是mysql_...

网站地图

All rights reserved Powered by www.5213.net

copyright ©right 2010-2021。
www.5213.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com