Hi... i follow your instruction here, but it didn't work...
focus on this:
foreach ($results as $row) {
echo "data.addRow(['{$row['foo']}', {$row['bar']}]);";
}
So, if u have 3 or more rows, you will have:
data.addRow(['{$row['foo']}', {$row['bar']}]);data.addRow(['{$row['foo']}',
{$row['bar']}]);data.addRow(['{$row['foo']}', {$row['bar']}]);
well, that will not work.
On Thursday, October 20, 2011 at 9:07:05 PM UTC+7, asgallant wrote:
>
> If you really don't want to use JSON, you can build the javascript with
> PHP directly. As an example, put this inside the <script>:
>
> google.load('visualization', '1', {packages: ['corechart']});
> google.setOnLoadCallback(drawChart);
>
> function drawChart () {
> var data = new google.visualization.DataTable();
> data.addColumn('string', 'foo');
> data.addColumn('number', 'bar');
> <?php
> // query MySQL and put results into array $results
> foreach ($results as $row) {
> echo "data.addRow(['{$row['foo']}', {$row['bar']}]);";
> }
> ?>
> var chart = new google.visualization.BarChart('chart_div');
> chart.draw(data, <options>);
> }
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/f6c3f63b-99d7-4084-a639-71ee2a84be28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.