Google charts expects the JSON to be formatted in the following way:
cols: [{id: 'task', label: 'Task', type: 'string'},
{id: 'hours', label: 'Hours per Day', type: 'number'}],
rows: [{c:[{v: 'Work', p: {'style': 'border: 7px solid orange;'}}, {v: 11}]},
{c:[{v: 'Eat'}, {v: 2}]},
{c:[{v: 'Commute'}, {v: 2, f: '2.000'}]}]};
If my PHP is set up as follows...
$data = array(
"cols" => array(
array("id"=>"", "label"=>"Topping", "pattern"=>"", "type"=>"string"),
array("id"=>"", "label"=>"Slices", "pattern"=>"", "type"=>"number")
),
"rows" => array();
);
How can I populate my "rows" array from a database using PHP while keeping an acceptable format for Google chart tools?
Thus far I am able to parse the data but the output is nothing like Google wants. It ends up looking like [{"number_of_toppings":"36"}].
Any help is GREATLY appreciated!!

New Topic/Question
Reply




MultiQuote






|