$datax
包含数字1
和2
(请参阅json
输出),但必须包含类似于1 / XXX
,2 / XXX
的条目等等($datax[] = $row['solution_id'] + " / " + $row['Type'];
)
错误在哪里?
<?php
include_once 'include/connect_db.php';
$query="SELECT A.solution_id, A.Type,A.Time2,B.Time1
FROM Table1 A
INNER JOIN Table2 B
ON A.Type=B.Type;";
$result=ejecutar_query($query);
$datax = array();
$datay1 = array();
$datay2 = array();
while($row=mysql_fetch_assoc($result)) {
$datax[] = $row['solution_id'] + " / " + $row['Type'];
$datay1[] = $row['Time1'];
$datay2[] = $row['Time2'];
}
echo json_encode(array('x' => $datax, 'y1' => $datay1, 'y2' => $datay2));
die();
?>
JSON
{“x”:[1,2,1,2,1,2,1,2,1,2,1,2],“y1”:[“2013-05-29 17:24:00 “” 2013年5月29日 17:24:00“,”2013-05-29 17:22:00“,”2013-05-29 17:22:00“,”2013-05-29 17:18:00“,”2013-05-29 17:18:00“,”2013-05-29 17:16:00“,”2013-05-29 17:16:00“,”2013-05-29 17:11:00“,”2013-05-29 17:11:00“,”2013-05-29 17:11:00“,”2013-05-29 17:11:00“],”y2“:[”2013-05-29 17:56:26“,”2013-05-29 18:03:38“,”2013-05-29 17:48:12“,”2013-05-29 17:42:53“,”2013-05-29 17:10:32“,”2013-05-29 17:52:08“,”2013-05-29 17:08:00“,”2013-05-29 17:10:18“,”2013-05-29 17:42:53“,”2013-05-29 17:06:12“,”2013-05-29 17:05:39“,”2013-05-29 18:09:00“]}
答案 0 :(得分:2)
在PHP中,.
是连接运算符
while($row=mysql_fetch_assoc($result)) {
$datax[] = $row['solution_id'] . " / " . $row['Type'];
$datay1[] = $row['Time1'];
$datay2[] = $row['Time2'];
}
答案 1 :(得分:1)
你必须在php中使用点运算符.
。所以$row['solution_id'] . " / " . $row['Type']
会有所帮助。