How do I populate the Google Chart API with my own Server side data i.e. in PHPMySQL.
Currently I have the following data:
function drawChart()
{
// Cre
Before the JavaScript-Code of the Charts API you have to get your data out of your database:
//Your database query goes here
$list = mysql_query("SELECT city,crimes FROM TABLE");
while($row = mysql_fetch_assoc($list)){
$data[] = "['".$row['city']."', ".$row['crimes']."]";
}
$data_for_chart = implode(",\n"$data);
Now replace in your JS-code:
data.addRows([
['Cardiff', 300],
['London', 900],
['Manchester', 500],
['Dublin', 400],
['Liverpool', 600]
]);
With:
data.addRows([
<?php echo $data_for_chart; ?>
]);