I am trying to format the encoded JSON array correctly. Here is my PHP MySQL Query:
$query = "SELECT date, value1, value2
FROM testdata
ORDER BY date ASC";
$result = mysql_query($query);
$myChartData = array();
while($row = mysql_fetch_assoc($result)){
$myChartData[] = $row;
}
<script type="text/javascript">
var chartData = <?php echo json_encode($myChartData); ?>;
On the console, the object is as follows:
[Object { date="2011-02-23", value1="133034", value2="12105.78"},
Object { date="2011-02-24", value1="122290", value2="12068.50"},
Object { date="2011-03-08", value1="453142", value2="12214.38"}]
The quotes around the date remain, but those that are on value1 and value2 must be removed.
Noob tutorial in all this ... Thanks for your help!
Eots source
share