google chart is not displaying

53 views
Skip to first unread message

Uvini Mithara

unread,
Sep 26, 2020, 3:08:24 AM9/26/20
to Google Visualization API
here's my code

<?php
$A = $_GET['date1'];
$B = $_GET['date2'];
$C = $_GET['cat'];

$connect = mysqli_connect("localhost","root","","csv");
$query = "SELECT * FROM file WHERE date>'$A' and date<'$B' ";
$result = mysqli_query($connect,$query);
$chart_data = '';

while($row = mysqli_fetch_array($result)){
$chart_data = "{date:'".$row["date"]."' , $C:".$row["$C"]."},";
}

$chart_data = substr($chart_data, 0, -2);
?>

<!DOCTYPE html>
<html>
 <head>
  <title></title>
 <style>
 body {
    font-family: Arial;
    width: 550px;
}

 </style> 


 </head>
 <body>
  <br /><br />
  <div class="container" style="width:900px;">
   <h2 align="center"><?php echo"The chart shows the $C data display" ?></h2>
   <h3 align="center"><?php echo"$A to $B" ?></h3>   
   <br /><br />
   
   
   <div id="chart"></div>
  </div>
 </body>
</html>

<script>
var C ="<?php echo $C ?>";
Morris.Line({
 element : 'chart',
 data:[<?php echo $chart_data; ?>],
 xkey:'date',
 ykeys:[C],
 labels:[C],
 hideHover:'auto',
 stacked:true
});
</script>
Reply all
Reply to author
Forward
0 new messages