Hallo Leute, ich versuche Stunden aus einer Timestamp-Spalte auf mySQL zu extrahieren. Ich erhalte eine Fehlermeldung währendEXTRAH HOUR FROM DATUM SQL PHP
tunSELECT EXTRACT(HOUR, time) FROM sensor;
WARNUNG: mysql_fetch_assoc() erwartet Parameter 1 Ressource zu sein, boolean gegeben 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 Versuch, diese auf einer Google-plotten Diagramm. Es arbeitet mit dem kompletten date.But ich möchte nur die
1) Überprüfen Sie auf Fehler statt blind anzunehmen, dass es funktioniert. Möglicherweise erhalten Sie einen Syntaxfehler. 2) mysql_ * Funktionen wurden in PHP7 entfernt und in früheren Versionen veraltet. Verhindern Sie Kopfschmerzen, indem Sie zu PDO oder mysqli wechseln. – aynber