$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";$result1 = mysql_query($sql1);while($row = mysql_fetch_array($result1)) { foreach($row as $ke=>$a){ echo $a."<br>"; }}
$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表的所有数据,为什么只输出一条数据的?求解答 1. 你的sql语句不会报错?order by asc,没有排序字段;
2. 没有执行 sql语句。mysql_query($sql1).
$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表的所有数据,为什么只输出一条数据的?求解答 1. 你的sql语句不会报错?order by asc,没有排序字段;
2. 没有执行 sql语句。mysql_query($sql1). 手误手误 ?
select * from y_cate order by asc的问题
order by没有指定字段,会报错:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "..........
$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>"; }}
select * from y_cate order by asc的问题
order by没有指定字段,会报错:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "..........
亲,手敲的代码,手误漏掉了。请问我问的问题怎么解决
$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>"; }}
while($row = mysql_fetch_array($result1,MYSQL_ASSOC)) {
foreach($row as $ke=>$a){
echo $a."
";
}
}
或者就用mysql_fetch_assoc/mysql_fetch_row