I am trying to display a chart using PHP and MySQL but it does not display
anything
here is my test.php file:
<html>
<head>
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
// Define the chart to be drawn.
var data = google.visualization.arrayToDataTable([
['Specialization', 'Facultyno'],
<?php
require_once('../mydb_connect.php');
$query="SELECT distinct(s.specializationname) as 'specialization',
count(fs.facultyid) as 'facultyno' from thesisdb.specialization s join
facultyspecialization fs on s.specializationid=fs.specializationid group by
s.specializationID";
$result = mysqli_query($dbc,$query);
while($row = mysqli_fetch_array($result))
{
echo "['".$row['specialization']."',
".$row['facultyno']."],";
}
?>
]);
var options = {'title':'Number of Faculty Specializations',
'width':1300,
'height':900};
}
// Instantiate and draw the chart.
var chart = new
google.visualization.ColumnChart(document.getElementById('no_of_specialization'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="no_of_specialization"/>
<?php
require_once('../mydb_connect.php');
$query="SELECT distinct(s.specializationname) as specialization,
count(fs.facultyid) as facultyno from thesisdb.specialization s join
facultyspecialization fs on s.specializationid=fs.specializationid group by
s.specializationID;";
// I was testing if the data can be displayed without the charts
$result = mysqli_query($dbc,$query);
while($row = mysqli_fetch_array($result))
{
echo "{$row['specialization']}<br>";
echo "{$row['facultyno']}<br>";
}
?> // it apparently worked
</body>
</html>
So there is a problem with my charts
here are my other references:
the result of the query I executed
<https://lh3.googleusercontent.com/-X6RnvFNtYFk/WeoUuVTm6XI/AAAAAAAAD4Q/5nzHX_2Kd1wC7wxmgPcz67NS_ZiCSBxLgCLcBGAs/s1600/Capture.PNG>
--
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/41f9136e-1478-4484-809d-ab13b302b830%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.