Hello guys I'm trying to extract hours from a timestamp column on mySQL. I get an error while doing
SELECT EXTRACT(HOUR, time) FROM sensor;
WARNING: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in ..
$sth = mysql_query("SELECT EXTRACT(HOUR, [time]) FROM sensor");
$rows = array();
//flag is not needed
$flag = true;
$table = array();
$table['cols'] = array(
// Labels for your chart, these represent the column titles
// Note that one column is in "string" format and another one is in "number" format as pie chart only required "numbers" for calculating percentage and string will be used for column title
array('label' => 'Date', 'type' => 'string'),
array('label' => 'Acum Energy', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
// the following line will be used to slice the Pie chart
$temp[] = array('v' => (string) $r['time']);
// Values of each slice
$temp[] = array('v' => (float) $r['value']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
//echo $jsonTable;
?>
Im trying to plot this on a google chart. It works with the complete date.But i just want to display the HOUR