php - Google Chart has no columns -


i hope can this.

i had working fine , it's stopped of sudden no reason. table has no columns error.

i got code site - http://mireille.it/example-code-realtime-google-chart-with-mysql-json-ajax/. not sure if helps or not.

here's code:

header

    <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">         // load visualization api , piechart package.         google.load('visualization', '1', {'packages':['corechart']});          // set callback run when google visualization api loaded.         google.setonloadcallback(drawchart);          function drawchart() {             var json = $.ajax({                 url: 'http://www.domain.com', // make url point data file                 datatype: 'json',                 async: false             }).responsetext;              // create our data table out of json data loaded server.             var data = new google.visualization.datatable(json);             var options = {                 title: 'active m&j players team assignment',                 is3d: 'true',                 width: 800,                 height: 600             };             // instantiate , draw our chart, passing in options.             //do not forget check ur div id             var chart = new google.visualization.piechart(document.getelementbyid('chart_div'));             chart.draw(data, options);              //setinterval(drawchart, 500 );         }     </script>  

php

    <?php /* $server = ip address or network name of server  * $username = user log database  * $password = database account password  * $databasename = name of database pull data  * table structure - colum1 cas: has text/description - column2 data has value  */ $con = mysql_connect('database', 'username', 'password') or die('error connecting server');  mysql_select_db('database', $con);   // write sql query here (you may use parameters $_get or $_post if need them) $query = mysql_query('select agelastsept ageorder,concat("u", agelastsept + 1 , "\'s") agelastsept,total members_family_view order ageorder asc');  $table = array(); $table['cols'] = array(     /* define datatable columns here      * each column gets own array      * syntax of arrays is:      * label => column label      * type => data type of column (string, number, date, datetime, boolean)      */     // assumed first column "string" type     // , second column "number" type     // can change them if not     array('label' => 'agelastsept', 'type' => 'string'),     array('label' => 'total', 'type' => 'number') );  $rows = array(); while($r = mysql_fetch_assoc($query)) {     $temp = array();     // each column needs have data inserted via $temp array     $temp[] = array('v' => $r['agelastsept']);     $temp[] = array('v' => (int) $r['total']); // typecast numbers appropriate type (int or float) needed - otherwise input strings      // insert temp array $rows     $rows[] = array('c' => $temp); }  // populate table rows of data $table['rows'] = $rows;  // encode table json $jsontable = json_encode($table);  // set header; first 2 prevent ie caching queries header('cache-control: no-cache, must-revalidate'); header('expires: mon, 26 jul 1997 05:00:00 gmt'); header('content-type: application/json');  // return json data echo $jsontable; ?> 

i have done obvious , checked sql query , works fine. keep getting table has no columns error.

thanks,

john


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -