Reputation: 16050
The $datax
contains numbers 1
and 2
(see json
output), however it must contain entries similar to 1 / XXX
, 2 / XXX
, etc. ($datax[] = $row['solution_id'] + " / " + $row['Type'];
)
Where is the error?
<?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-05-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"]}
Upvotes: 0
Views: 46
Reputation: 562
You have to use the dot operator .
in php. So $row['solution_id'] . " / " . $row['Type']
will help.
Upvotes: 1
Reputation: 891
In PHP, .
is the concatenation operator
while($row=mysql_fetch_assoc($result)) {
$datax[] = $row['solution_id'] . " / " . $row['Type'];
$datay1[] = $row['Time1'];
$datay2[] = $row['Time2'];
}
http://php.net/manual/en/language.operators.string.php
Upvotes: 2