hai sir i'm fresher to google charts..can anyone guide to connect the 
database

here is my coding..

<?php
$servername="localhost";
$username="root";
$password="";
$database="charts";
$mysqli=new mysqli($servername, $username, $password, $database);
if($mysqli->connect_error){
die("Connection Failed: " .$mysqli->connect_error);
}
$query="select * from piechart";
$qresult=$mysqli->query($query);
$results=array();
while($res=$qresult->fetch_assoc()){
$results[]=$res;
}
$pie_chart_data=array();
foreach($results as $result)
{
$pie_chart_data[]=array($result['status'],(int)$result['num of patitent']);
}
$pie_chart_data= json_encode($pie_chart_data);
mysqli_free_result($qresult);
?>
<html>
  <head>
    <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([$pie_chart_data]);

        var options = {
          title: 'My Daily Activities'
        };

        var chart = new 
google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="piechart" style="width: 900px; height: 500px;"></div>
  </body>
</html>

-- 
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/631ceac4-4105-471f-a2e3-ef6b39b2710b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to