my php code is working and is giving an output.. but the pie chart (html 
part) is not working.. can anyone help me solve this??


   1. <?php
   2. $con=mysqli_connect("localhost","root","","test");
   3. 
   4. if (mysqli_connect_errno())
   5. {
   6. echo "Failed to connect to MySQL: " . mysqli_connect_error();
   7. }
   8. 
   9. if(isset($_POST['pie1']))
   10. {
   11. $to= $_POST['to'];
   12. 
   13. $from= $_POST['from'];
   14. $query = mysqli_query($con,"SELECT COUNT(mrd),del FROM lr WHERE 
   DATE(dod) >= '$from' and DATE(dod) <= '$to' and sno!=0 GROUP BY del");
   15. 
   16. while ($row=mysqli_fetch_array($query))
   17. {
   18. $pp=array();
   19. $per=array();
   20. $per[]=$row['del'];
   21. $arr2=array_keys($row);
   22. $arr1=array_values($row);
   23. for ($i=0;$i<count($per);$i++)
   24. {
   25. $pp[$i]=$row[0]/100;
   26. echo "<pre>";
   27. echo"$row[1]";
   28. echo"\t";
   29. echo"$row[0]";
   30. echo"\t";
   31. echo" $pp[$i]";
   32. echo"<br>";
   33. }
   34. echo "<pre>";
   35. $k=count($arr1);
   36. 
   37. 
   38. echo "<pre>";
   39. }
   40. 
   41. $query = mysqli_query($con,"SELECT COUNT(mrd),del FROM lr WHERE 
   DATE(dod) >= '$from' and DATE(dod) <= '$to' and sno!=0 GROUP BY del");
   42. while ($row=mysqli_fetch_array($query))
   43. {
   44. $kk=count($per);
   45. echo"$kk";
   46. for ($i=0;$i<$kk;$i++)
   47. {
   48. 
   49. 
   50. $chart_array[$i]=array((string)$row[$i],intval($pp[$i]));
   51. }
   52. 
   53. 
   54. $data=json_encode($chart_array);
   55. print_r($data);
   56. }
   57. }
   58. 
   59. ?>
   60. 
   61. 
   62. <html>
   63. <head>
   64. <!--Load the AJAX API-->
   65. <script type="text/javascript" src="https://www.google.com/jsapi";
   ></script>
   66. <script type="text/javascript" src="
   http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js";
   ></script>
   67. <script type="text/javascript">
   68. 
   69. // Load the Visualization API and the piechart package.
   70. google.load('visualization', '1', {'packages':['corechart']});
   71. 
   72. // Set a callback to run when the Google Visualization API is loaded.
   73. google.setOnLoadCallback(drawChart);
   74. 
   75. function drawChart() {
   76. 
   77. // Create our data table out of JSON data loaded from server.
   78. var data = new google.visualization.DataTable();
   79. data.addColumn("string", "Type of Delivery");
   80. data.addColumn("number", "% in no");
   81. 
   82. data.addRows(<?php $data ?>);
   83. 
   84. ]); 
   85. var options = {
   86. title: 'REPORT',
   87. is3D: 'true',
   88. width: 800,
   89. height: 600
   90. };
   91. 
   92. var chart = new google.visualization.PieChart(document.getElementById
   ('chart_div'));
   93. chart.draw(data, options);
   94. }
   95. </script>
   96. </head>
   97. 
   98. <body>
   99. <!--Div that will hold the pie chart-->
   100. <div id="chart_div"></div>
   101. </body>
   102. </html>



this code gives the output as

FORCEPS WITH RMLE 1 0.01
FTND WITH RMLE 20 0.2
LSCS 7 0.07
LSCS, GA 7 0.07
LSCS, SA 16 0.16
LSCS, TUBECTOMY 3 0.03
1[["1",0]]1[["20",0]]1[["7",0]]1[["7",0]]1[["16",0]]1[["3",0]]

-- 
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to