columnchart没有使用php和mssql显示任何结果

时间:2016-12-26 07:17:52

标签: php sql-server

我创建了一个管理面板,我想显示柱形图和饼图。我做了部分代码和我的饼图工作,但colum图表没有显示任何结果或没有错误。

我的代码如下: -

<?php
$serverName = "localhost"; 
$connectionInfo = array( "Database"=>"TripBrip", "UID"=>"", "PWD"=>"");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
?>
<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>

    <script type="text/javascript">
    google.load("visualization", "1", {packages:["corechart"]});
    google.setOnLoadCallback(drawChart);
    function drawChart() {
      var data = google.visualization.arrayToDataTable([
          ['date_of_journey', 'Booking'],
            <?php 

                $query = "SELECT count(booking_id) AS count, date_of_journey FROM tbl_booking GROUP BY date_of_journey ORDER BY date_of_journey";
                $exec = sqlsrv_query($con,$query);
                while($row = sqlsrv_fetch_array($exec)){
                    echo "['".$row['date_of_journey']."',".$row['count']."],";
                }
       ?>

        ]);
        var options = {
            title: 'Date wise booking'
        };
      var chart = new google.visualization.ColumnChart(document.getElementById("columnchart"));
      chart.draw(data, options);
  }
  </script>

  </head>
  <body>
  <h3>Column Chart</h3>
   <div id="columnchart" style="width: 900px; height: 500px;"></div>
  </body>
</html>

任何人都可以帮助我如何解决这个问题

0 个答案:

没有答案