Also, when I go to GetTableData1.php directly, here's what the data looks
like:
{"cols":[{"id":"name","label":"Name","type":"string"},{"id":"count","label":"Count","type":"number"}],"rows":[{"c":[{"v":"Anthony
D"},{"v":5}]},{"c":[{"v":"Bill C"},{"v":4}]},{"c":[{"v":"Bobby
M"},{"v":8}]},{"c":[{"v":"Daniel M"},{"v":6}]},{"c":[{"v":"Dino
M"},{"v":9}]},{"c":[{"v":"Jason S"},{"v":4}]},{"c":[{"v":"Jim
H"},{"v":8}]},{"c":[{"v":"Tommy D"},{"v":1}]}]}
On Tuesday, November 5, 2013 5:07:19 PM UTC-5, GoogleChartsNewbie wrote:
>
> Hi all.
>
> I'm trying to load data into a Google Chart Table but unfortunately, the
> table is not being displayed. Any idea what I'm doing wrong? Thank you in
> advance.
>
> *ChartTable.html:*
> *
> *
> <html>
> <head>
> <!--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="https://www.google.com/jsapi
> "></script>
> <script type="text/javascript" src="
> http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
> <script type="text/javascript">
> google.load('visualization', '1', {packages:['table']});
> google.setOnLoadCallback(drawTable);
> function drawTable() {
> var jsonData = $.ajax({
> url: "GetTableData1.php",
> dataType:"json",
> async: false
> }).reponseText;
> var data = new google.visualization.DataTable(jsonData);
> var table = new
> google.visualization.Table(document.getElementById('table_div'));
>
> table.draw(data, {showRowNumber: true});
> }
> </script>
> </head>
> <body>
>
> <div id="table_div"></div>
>
>
> </body>
> </html>
>
> *GetTableData1.php:*
>
> <?php
> require("common.php");
>
> $smt = $db->prepare('SELECT Concat(firstname ," " ,lastname) as Name,
> count(buildercommunityid) as Count FROM Users INNER JOIN
> FieldSuperAssignment ON Users.userid = FieldSuperAssignment.UserID Group by
> Users.userid order by firstname');
> $smt->execute();
> $data = $smt->fetchAll();
>
> $rows = array();
> $table = array();
> $table['cols'] = array(
> array('id'=> 'name', 'label' => 'Name', 'type' => 'string'),
> array('id' => 'count', 'label' => 'Count', 'type' => 'number')
> );
>
> foreach($data as $row) {
> $temp = array();
> $temp[] = array('v' => (string) $row['Name']);
> $temp[] = array('v' => (int) $row['Count']);
> $rows[] = array('c' => $temp);
> }
>
> $table['rows'] = $rows;
> $jsonTable = json_encode($table);
> echo $jsonTable;
> ?>
>
--
You received this message because you are subscribed to the Google Groups
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/groups/opt_out.