Can not view Google Column Chart on webpage

Hi all.

I have the following files that I want to use to display a column chart on my website. Unfortunately, the code below is simply displaying a blank page. Do I have something wrong in the code that is not displaying the column chart?

    <!--Load the AJAX API-->
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
    <meta content="utf-8" http-equiv="encoding" />
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});

 function drawChart1() {
  var jsonData1 = $.ajax({
          url: "GetChartData1.php",
          async: false
        // Create our data table out of JSON data loaded from server
        var data = new google.visualization.DataTable(jsonData1);
  var options = {'title':'Super Workload',

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.ColumnChart(document.getElementById('chart_div1'));
        chart.draw(data, options);


 <div id="chart_div1"></div> 

Open in new window

// First we execute our common code to connection to the database and start the session 

    $smt = $db->prepare('SELECT Count(Type) as Count, firstname FROM FieldSuperDataEntry INNER JOIN Users ON DataEntry.UserID = Users.userid Group By firstname')
    $data = $smt->fetchAll(); 
  $rows = array();
  $table = array();
  $table['cols'] = array(
    array('label' => 'firstname', 'type' => 'string'),
    array('label' => 'Count', 'type' => 'number')

foreach($data as $row) {
      $temp = array();
      $temp[] = array('v' => (string) $row['firstname']); 
      $temp[] = array('v' => (int) $row['Count']); 
      $rows[] = array('c' => $temp);

$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;

Open in new window

Thank you in advance.
Who is Participating?
leakim971Connect With a Mentor PluritechnicianCommented:
open the page GetChartData1.php directly in your brozser with the full URL of course and post what you get
Sim1980Author Commented:
Thanks! I did what you suggested and the output was an error, I misspelled a field in the sql statement.

I'm going to post another question because I want to be able to show 2 counts and a sum, so it would be 3 bar graphs per user.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.