php循环输出数组 不能读取,该如何解决
程序员文章站
2022-05-17 19:02:18
...
php循环输出数组 不能读取
$cart = mysql_query("select * from qiyu_cart where cart_order=410010268");
while($row11=mysql_fetch_array($cart)){
$cart1 = mysql_query("select * from qiyu_food where food_id=".$row11['cart_food']);
$row1=mysql_fetch_array($cart1);
$arr= array($row1['food_name']."
"
);
echo $arr."
";
}
我想做出输出一组数据,
$arr.输出的如果怎么是array 而不是$row1['food_name'].的内容 是哪里错了吗。?
------解决思路----------------------
$arr= array($row1['food_name']."
"
应为
$arr[] = array($row1['food_name'])
或
$arr .= $row1['food_name']. "
";
echo $arr."
";
应为
echo join('
' $arr) ."
";
或
echo $arr."
";
$cart = mysql_query("select * from qiyu_cart where cart_order=410010268");
while($row11=mysql_fetch_array($cart)){
$cart1 = mysql_query("select * from qiyu_food where food_id=".$row11['cart_food']);
$row1=mysql_fetch_array($cart1);
$arr= array($row1['food_name']."
"
);
echo $arr."
";
}
我想做出输出一组数据,
$arr.输出的如果怎么是array 而不是$row1['food_name'].的内容 是哪里错了吗。?
------解决思路----------------------
$arr= array($row1['food_name']."
"
应为
$arr[] = array($row1['food_name'])
或
$arr .= $row1['food_name']. "
";
echo $arr."
";
应为
echo join('
' $arr) ."
";
或
echo $arr."
";
相关文章
相关视频
- 详解win10下PHP的安装配置(以php5.6为...
- php Swoole实现毫秒定时计划任务(详解)
- 【DTM】PHP协程客户端v0.1 beta版本发...
- PHP中类的理解和应用[一]_PHP教程
- php循环输出数组 不能读取,该如何解决