关于foreach输出问题
$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." ";
}
?>
我想用foreach 来循环输出cate表的所有数据,为什么只输出一条数据的?求解答
分享到: ------解决方案--------------------
$sql1="select * from y_cate order by asc";<br />
$result1 = mysql_query($sql1);<br />
while($row = mysql_fetch_array($result1)) {<br />
foreach($row as $ke=>$a){<br />
echo $a."<br>";<br />
}<br />
}
Copy after login
Copy after login
------解决方案-------------------- 1. 你的sql语句不会报错?order by asc,没有排序字段;
2. 没有执行 sql语句。mysql_query($sql1). ------解决方案--------------------
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