0

I am reading data from a mysql db to my webpage. I wish to make a google pi-chart but have no idea how to pass the data from php (html?) to javascript(?) to populate the graph. I'm reading the rows into the html page ok, they are dispaying in a table. Any help will be much appreciated. Thanks.

 <?php 
  do { 
    if($row_getaccounts['category'] != 'transfer')  {
        if($row_getaccounts['category'] != 'balance' ){           
        if($row_getaccounts['amount'] > 0){?>
            <tr>
            <td>
            <?php 
                echo $row_getaccounts['category'];  
            ?>
            </td>
            <td align="right">
            <?php 
                $english_format_number = number_format($row_getaccounts['amount'], 2, '.', '');echo $english_format_number; 
            ?>
            </td>
    </tr>
        <?php }
        }
        } 
    } while ($row_getaccounts = mysql_fetch_assoc($getaccounts)); ?>


<?php
$query_getaccounts = "SELECT * FROM `$tempcat`ORDER BY `category`ASC";
$getaccounts = mysql_query($query_getaccounts, $dmsdb) or die(mysql_error());
$row_getaccounts = mysql_fetch_assoc($getaccounts);
$totalRows_getaccounts = mysql_num_rows($getaccounts);
$index="&chdl="; 
$graphstring="&chl=";
do { 
  if($row_getaccounts['amount'] < 0){
    $graphstring = $graphstring.$row_getaccounts['category']."|";
    $index=$index.$row_getaccounts['category']."|";
    }   
}
while ($row_getaccounts = mysql_fetch_assoc($getaccounts)); 
?>

<p align="center"><img src="http://chart.apis.google.com/chart?chs=320x225&cht=p&chd=s:k5xl<?php echo $graphstring; ?>&chma=10,10,10,10&chtt=categories" width="320" height="225" alt="categories" /></p>

Edited by Dani: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by Ichcha
0

hi i have just worked with google apps column chart. from my reasearch on google apps.. the charts will be created based on google.visualization.DataTable,it cannot take the data by itself. get your php variable from javascript using json_encode.

Edited by Ichcha: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.