Nothing works:(
You can view results of php @ sunminer.co/getData.php
//connection successful...
$sth = mysql_query("SELECT * FROM testpower WHERE datetime > 0");
$rows = array();
$flag = true;
while($r = mysql_fetch_assoc($sth)) {
$rows[] = $r;
}
$tablej = '{cols:[{label: \'date\', type: \'datetime\'}, {label: \'power\', type: \'number\'}], rows: [';
foreach($rows as $i){
if ($flag){
$tablej .= '{c: [{v:'.$i["datetime"].'},{v:'.$i["power"].'}]}';
$flag = false;
}
else
$tablej .= ', {c: [{v:'.$i["datetime"].'},{v:'.$i["power"].'}]}';
}
$tablej .= ']}';
//__________________________________________________________________________________________________________
header("Content-type: application/json");
echo $tablej;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Google Visualization API Sample</title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript" src="jquery-1.6.2.min.js"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['annotatedtimeline']}); function drawVisualization() { var data = new google.visualization.DataTable({cols:[{label: 'date', type: 'datetime'}, {label: 'power', type: 'number'}], rows: [{c: [{v:'2007-12-01 00:12:00'},{v:0}]}, {c: [{v:'2007-12-01 01:12:00'},{v:101}]}, {c: [{v:'2007-12-01 02:12:00'},{v:201}]}, {c: [{v:'2007-12-01 03:12:00'},{v:302}]}]}); var annotatedtimeline = new google.visualization.AnnotatedTimeLine( document.getElementById('visualization')); annotatedtimeline.draw(data, {'displayAnnotations': true}); } google.setOnLoadCallback(drawVisualization); </script> </head> <body style="font-family: Arial;border: 0 none;"> <div id="visualization" style="width: 800px; height: 400px;"></div> </body> </html>
$sth = mysql_query("SELECT * FROM testpower WHERE datetime > 0");
$rows = array();
$flag = true;
$table = array();
$table['cols'] = array(
array('label' => 'date', 'type' => 'datetime'),
array('label' => 'power', 'type' => 'number')
);
$rows = array();$temp[] = array('v' => $i['datetime']); // you will probably need to transform this into the Date object format
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
sunminer.net/getData.php
$table = array();
$table['cols'] = array(
array('label' => 'date', 'type' => 'datetime'),
array('label' => 'power', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$dateTimeArr = explode(' ', $i['datetime']);
$dateArr = explode('-', $dateTimeArr[0]);
$timeArr = explode(':', $dateTimeArr[1]);$year = $dateArr[0];
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);