Google Chart with Database.

<?php
include("db.php");
$query = "select * from warehouse";
if ($result = mysql_query($query)) {
    {
    $rows = array();
    $table = array();
    $table['cols'] = array(
            array('label' => 'Warehouse', 'type' => 'string'),
            array('label' => 'Percentage', 'type' => 'number')
    );
    while ($row =mysql_fetch_array($result)) {
$begani=mysql_fetch_array(mysql_query("select sum(stcokprice) from beganinventory where warehouse='$row[2]'"));
$a="warehouse";
$b=200;
            $temp = array();
            $temp[] = array('v' => (string) $row[2]);
            $temp[] = array('v' => (int) $begani[0]);
            $rows[] = array('c' => $temp);
            }
   }
 }
$table['rows'] = $rows;
$jsonTable = json_encode($table);
?>


<link href="myadminstyle.css" rel="stylesheet" type="text/css" />
  <script>
           $(document).ready(function() {
   $( "#fromdate" ).datepicker({ dateFormat: 'yy-mm-dd' });
$( "#todate" ).datepicker({ dateFormat: 'yy-mm-dd' });
$("#description1").change(function() {
var id = $(this).val();
$.ajax({
            url: 'load123.php',
            type: 'POST',
            dataType: 'json',
            data:{
'id':$(this).val(),
'dd':$("#taxlocation").val()
},
            success: function(data)
            {
                 $("#Sku1").val(data[0].sku);
        $("#Uom1").val(data[0].uom);
        $("#Price1").val(data[0].defaultprice);
         $("#Tax1").val(data[0].aa);
$("#eanupc1").val(data[0].bar);
$("#purprice1").val(data[0].sp);
$("#stockamount1").val(data[0].sa);
            }
        });
});
  });


  </script>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
 <script type="text/javascript">
 // Load the Visualization API and the piechart package.
 google.load('visualization', '1', {'packages':['corechart']});
 // Set a callback to run when the Google Visualization API is loaded.
 google.setOnLoadCallback(drawChart);
 function drawChart() {
  // Create our data table out of JSON data loaded from server.
  var data = new google.visualization.DataTable(<?php echo $jsonTable?>);
  var options = {
       title: 'Stats',
      is3D: 'true',
      width: 800,
    height: 600
    };
  // Instantiate and draw our chart, passing in some options.
  // Do not forget to check your div ID
  var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}
</script>

<div id="chart_div"></div>




Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.