Hi,
how can I connect the Google Pie Chart with a MySQL database?
My following code doesn't work :-(
<?php
$con=mysqli_connect("localhost","User","Password,"testdb");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql = 'SELECT COUNT(*)-SUM(testcolumn) AS 'YesOrNo' FROM testtable';
$yes = mysql_query ( $sql );
$sql = 'SELECT COUNT(*)-SUM(testcolumn) AS 'YesOrNo' FROM testtable';
$no = mysql_query ( $sql );
?>
<html>
<head>
<script type="text/javascript"
src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['YesOrNo', 'Mount'],
['Yes', $yes],
['No', $no]
]);
var options = {
title: 'Test Pie Chart',
is3D: true,
};
var chart = new
google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="piechart_3d" style="width: 900px; height: 500px;"></div>
</body>
</html>
Thanks for helping!
--
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/groups/opt_out.