我的代码正常工作并显示数据。但是,当我添加谷歌图表时,它不会显示任何数据,也不会出现错误。我需要修改什么吗?它显示为空白页面。但是当我运行没有谷歌柱形图的代码时,它显示数据。
这里是我的密码
<?php
include 'login_success.php';
$user='root';
$pass='';
$db='mypro_bms';
$conn = mysqli_connect('localhost',$user,$pass,$db);
$count=0;
if(isset($_POST['search'])){
$txtStartDate=$_POST["txtStartDate"];
$txtEndDate=$_POST["txtEndDate"];
$q=mysqli_query($conn,"SELECT blood_group, SUM(blood_bag) as sum FROM donate where donation_date BETWEEN '$txtStartDate' and '$txtEndDate' group by blood_group");
$count=mysqli_num_rows($q);
}
?>
<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([
['sum','blood_group'],
<?php
if ($count=="0")
{
echo "No data"; }
else
{
while ($row=mysqli_fetch_array($q)) {
echo"['".$row['blood_group']."',".$row['sum']."],";
}
}
?>
]);