I retrieve information from php in Json form to pass it in my chart which is working by javascript and i already pass from php to javascript correctly, but when I use this javascript in the chart, the chart stop working
$result = mysql_query("select * from employee", $db);
//Create an array
$json_response = array();
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$row_array['date'] = $row['date'];
$row_array['rate'] = $row['rate'];
//push the values in the array
array_push($json_response,$row_array);
}
$all= json_encode($json_response);
echo($all);
//Close the database connection
mysql_close($db);
?>
<script >
var data_from_php = '<?php echo $all; ?>';
alert(data_from_php);
var data = [{
"date":"2012-03-01",
"rate":"6"
}, {
"date": "2012-03-02",
"rate": "-10"
}, {
"date": "2012-03-03",
"rate": "1"
},
{
"date": "2012-03-03",
"rate": "1"
},
{
"date": "2012-03-04",
"rate": "5"
},
{
"date": "2013-03-05",
"rate": "10"
},
{
"date": "2013-04-03",
"rate": "-5"
},
{
"date": "2013-05-10",
"rate": "-2"
}]
var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
"theme": "light",
"marginTop":0,
"marginRight": 80,
"pathToImages": "http://www.amcharts.com/lib/3/images/",
"dataProvider": data,
"valueAxes": [{
"axisAlpha": 0,
"position": "left"
}],
well , I used data manual in Json form to see if the chart is working and I alert the variable which I recieved it from php and convert it to Javascript and all working good