1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
<?php
$con = mysqli_connect("localhost","root","root","appinfo");
if($con){
echo "connected";
}
?>
<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([
['students', 'contribution'],
<?php
$sql = "SELECT * FROM contribution";
$fire = mysqli_query($con,$sql);
while ($result = mysqli_fetch_assoc($fire)) {
echo"['".$result['student']."',".$result['contribution']."],";
}
?>
]);
var options = {
title: 'Students and their contribution'
};
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> |
Partager