显示饼图时出现问题。似乎sql很好,因为我在数据库本身上尝试了它,并且效果很好。我得出的结论是,图表是不显示饼图的问题。我不知道是什么问题。非常感谢你 .............................................. ....
<?php
if(isset($_POST['submitbttn'])){
$dFrom = $_POST['dateFrom'];
$dTo = $_POST['dateTo'];
?>
<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([
['District', '<?php echo $dFrom;?> <?php echo $dTo;?> Dengue'],
['North',
<?php
mysql_connect("localhost","root",""); //phpmyadmin username and pass
mysql_select_db("lcho_login"); //your database name needs to access
$sql=mysql_query("SELECT SUM(`deng_case_ind1`) AS ind_num FROM lcho_dengue_cases2 WHERE `date` between '". $dFrom ."' and '".$dTo."' ");
$indicator10='ind_num'; // name column in the table
while($row = mysql_fetch_array( $sql )) {
echo $row['ind_num'];
}
?>
],
['South',
<?php
$sql=mysql_query("SELECT SUM(`deng_case_ind2`) AS ind_num FROM lcho_dengue_cases2 WHERE `date` between '". $dFrom ."' and '".$dTo."' ");
$indicator10='ind_num'; // name column in the table
while($row = mysql_fetch_array( $sql )) {
echo $row['ind_num'];
}
?>
],
['East',
<?php
$sql=mysql_query("SELECT SUM(`deng_case_ind3`) AS ind_num FROM lcho_dengue_cases2 WHERE `date` between '". $dFrom ."' and '".$dTo."' ");
$indicator10='ind_num'; // name column in the table
while($row = mysql_fetch_array( $sql )) {
echo $row['ind_num'];
}
?>
],
['West',
<?php
$sql=mysql_query("SELECT SUM(`deng_case_ind4`) AS ind_num FROM lcho_dengue_cases2 WHERE `date` between '". $dFrom ."' and '".$dTo."' ");
$indicator10='ind_num'; // name column in the table
while($row = mysql_fetch_array( $sql )) {
echo $row['ind_num'];
}
?>
],
['Urban',
<?php
$sql=mysql_query("SELECT SUM(`deng_case_ind5`) AS ind_num FROM lcho_dengue_cases2 WHERE `date` between '". $dFrom ."' and '".$dTo."' ");
$indicator10='ind_num'; // name column in the table
while($row = mysql_fetch_array( $sql )) {
echo $row['ind_num'];
}
?>
]
]);
var options = {
title: 'Lipa City dengue as of <?php echo $dFrom;?>.'to' .<?php echo $dTo; ?>',
is3D: true,
};
var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
chart.draw(data, options);
}
</script>
<div class="breadcrumbs">
<div class="col-sm-10">
<div class="page-header float-center">
<div class="page-title">
<form action="#" method="post">
<div class="container">
<div class="col-sm-3">
<div class="form-group">
<label for="dateFrom">From: </label>
<input class="form-control" type="date" id="dateFrom" name="dateFrom">
</div>
</div>
<label for="dateTo">To: </label>
<input class="form-control" type="date" id="dateTo" name="dateTo">
</div>
</div>
继续
</form>
</div>
</div>
</div>
</div>
<?php if(isset($_POST['submitbttn'])){
$dFrom = $_POST['dateFrom']; //get input text
$dTo = $_POST['dateTo']; //get input text
$text = "<h1>Dengue Summary</br> Lipa City || ". $dFrom . " ".$dTo." </h1>";
echo $text;
}
else{
echo " </br></br><h1> Please select month and year!! </h1> ";
}
?>
<div id="piechart_3d" style="width: 100%; height:900px;"></div>