Hi I have a basic Pie Chart that, upon running the PHP script and viewing 
the page source in the browser shows that the data is retrieved correctly 
using mysql_fetch_array()
however, no pie chart is displayed in the browser.  here is the php script

<!DOCTYPE html>
<?php

include("config.php");
$my_db = "asmf";
$link = mysqli_connect($dbhost, $dbuname, $dbpass, $my_db);
$q = "select * from $my_db.expenses GROUP BY exp_type";
$r = mysqli_query($link, $q);

if (!$link) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

?>

<html>
  <head>
    <title>ASMF-eTrucker Expense Pie Chart</title>
    <script type="text/javascript" 
src="https://www.gstatic.com/charts/loader.js";></script>
    <script type="text/javascript">
    google.charts.load("current", {packages:["corechart"]});
    google.charts.setOnLoadCallback(drawChart);
    function drawChart() {
      var data = google.visualization.arrayToDataTable([
       ['Expense Type', 'Amount'],
      <?php
        while($row = mysqli_fetch_array($r)) {
    //echo $row["amount"]."<br>";
      echo "['".$row['exp_type']."', '".$row['amount']."'],";
    }
      ?>
      ]);
      var options = {
        title: 'Percent of Expense Types' 
      };
      var chart = new 
google.visualization.PieChart(document.getElementById('piechart'));
      chart.draw(data, options);
    }
    </script>
  </head>
  <body>
    <div style="width:900px;">
      <h3>ASMF-eTrucker Expense Pie Chart</h3>
      
      <br />
      <div id="piechart" style="width: 900px; height: 500px;"></div>
    </div>

Where could the code be failing?

Gregg

-- 
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/ce64d09c-d916-4cbc-8bf7-409959b9824c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to