0
我想将两行中的两个值添加到数组中。一个是路径,另一个是标签。然后我编码数组。所以我可以显示图像,然后我将使用这些标签来动态订购新的JavaScript数组。我想要“echo $ data”说类似[{路径,标签},{路径,标签}]如何将两个sql行添加到php数组中
<?php
include("mysqlconnect.php");
$select_query = "SELECT `ImagesPath`,`Tag` FROM `offerstbl` ORDER by `ImagesId` DESC";
$sql = mysql_query($select_query) or die(mysql_error());
$data = array();
while($rows = mysql_fetch_array($sql,MYSQL_BOTH)){
$data[] = $rows['ImagesPath']['Tag'];
}
echo json_encode($data);
echo $data[0];
?>
u得到什么样的价值,同时呼应 – 2014-08-27 14:33:25
[” h“,”h“,”h“,”h“,”h“]表示全部回声,h表示单个回声。这对我来说没有意义。 h不代表数据库中的任何内容 – James121 2014-08-27 14:35:58