I want to create a Google graph from some data in my database, now I have this code:
<?php
$q = mysql_connect('localhost', 'xxx', 'xxx');
mysql_select_db('xxx', $q);
?>
<?php
$sth = mysql_query("SELECT inkoop, verkoop FROM prijs WHERE inkoop >= 1 ");
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
print json_encode($rows);
?>
<?php
$sth = mysql_query("SELECT tijd FROM prijs WHERE inkoop >= 1");
$cols = array();
while($c = mysql_fetch_assoc($sth)) {
$cols[] = $c;
}
print json_encode($cols);
?>
And it gives me this output:
[{"inkoop":"516","verkoop":"484"},{"inkoop":"515","verkoop":"488"},{"inkoop":"515","verkoop":"487"}][{"tijd":"2013-12-17 23:45:00"},{"tijd":"2013-12-17 23:48:00"},{"tijd":"2013-12-17 23:52:00"}]
What I need is something like this, to create a line graph:
{
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
}
Edit: I need a line graph with 2 lines one for 'inkoop' and one for 'verkoop', if I can use something like this link it would be even better.
Thanks in advance!