关于foreach输出问题?php$sql1select * from y_cate order by asc$result1mysql_fetch_array(mysql_
关于foreach输出问题 <?php $sql1="select * from y_cate order by asc"; $result1=mysql_fetch_array(mysql_query($sql1)); var_dump($result1); foreach($result1 as $ke=>$a){ echo $a."<br>"; } ?> 我想用foreach 来循环输出cate表的所有数据,为什么只输出一条数据的?求解答
[解决办法]
$sql1="select * from y_cate order by asc"; $result1 = mysql_query($sql1); while($row = mysql_fetch_array($result1)) { foreach($row as $ke=>$a){ echo $a."<br>"; } }
[解决办法] 1. 你的sql语句不会报错?order by asc,没有排序字段; 2. 没有执行 sql语句。mysql_query($sql1). [解决办法]