I want to load data from my MySQL server with php code and then use it to draw chart with google charts. the problem is that i can't use the data that quered from my mysql in the java-script code.
PHP code :
$connection = mysql_connect('127.0.0.1','root','123456');
mysql_select_db('db_statmarket',$connection);
$result2 = mysql_query('select sum(`How much read from customer`) as Leads, Date from monitor group by Date;',$connection) or die('cannot show tables');
Here in the javascript code where we can see the var data = ...
i want that he will be the table that i quered from my database.
HTML & JS code :
<script type="text/javascript">
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
curveType: 'function',
legend: { position: 'bottom' }
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
The output need to be seen like these:
Aucun commentaire:
Enregistrer un commentaire