You don't have to be an expert to make this work, JSON is just a string 
representation of your data.  For example, if you queried MySQL for columns 
"foo" and "bar", your code might look something like this:

// $json holds the JSON string
$json = '{"cols": [{"id": "foo", "label": "Foo", "type": "string"}, {"id": 
"bar", "label": "Bar", "type": "number"}], "rows": [';

// $results is an associative array holding the results of the query
foreach ($results as $row) {
     // add $row["foo"] to the first column in each row, and add $row["bar"] 
to the second column in each row
     $json .= '{"c": [{"v": "'. $row["foo"]. '"}, {"v": '. $row["bar"]. 
'}]}, ';
}
$json .= ']}';

// set header
header("Content-type: application/json");
// return data
echo $json;

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to