Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>use this, it realy works:</p> <p>data.addColumn no of your key, you can add more columns or remove </p> <pre><code>&lt;?php $con=mysql_connect("localhost","USername","Password") or die("Failed to connect with database!!!!"); mysql_select_db("Database Name", $con); // The Chart table contain two fields: Weekly_task and percentage //this example will display a pie chart.if u need other charts such as Bar chart, u will need to change little bit to make work with bar chart and others charts $sth = mysql_query("SELECT * FROM chart"); while($r = mysql_fetch_assoc($sth)) { $arr2=array_keys($r); $arr1=array_values($r); } for($i=0;$i&lt;count($arr1);$i++) { $chart_array[$i]=array((string)$arr2[$i],intval($arr1[$i])); } echo "&lt;pre&gt;"; $data=json_encode($chart_array); ?&gt; &lt;html&gt; &lt;head&gt; &lt;!--Load the AJAX API--&gt; &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; // 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(); data.addColumn("string", "YEAR"); data.addColumn("number", "NO of record"); data.addRows(&lt;?php $data ?&gt;); ]); var options = { title: 'My Weekly Plan', is3D: 'true', width: 800, height: 600 }; // Instantiate and draw our chart, passing in some options. //do not forget to check ur div ID var chart = new google.visualization.PieChart(document.getElementById('chart_div')); chart.draw(data, options); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!--Div that will hold the pie chart--&gt; &lt;div id="chart_div"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload