【发布时间】:2014-04-22 11:56:32
【问题描述】:
我正在尝试连接几个 json 键值,以便我可以只返回一个包含所有数据的值。例如,在我的代码中,我想将地址 1、地址 2、地址 3 组合成地址。这可能吗。我尝试了各种使用 .= 的方法,但似乎没有任何效果。任何抬头将不胜感激。谢谢
$query = "SELECT * FROM company_com";
$from = 0;
$to = 30;
$query .= " LIMIT ".$from.",".$to;
$result = mysql_query($query) or die("SQL Error 1: " . mysql_error());
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$customers[] = array(
'Address1' => $row['address1_com'],
'Address2' => $row['address2_com'],
'Address3' => $row['address3_com']
);
}
echo json_encode($customers);
【问题讨论】: