我试图从数据库中获取每天的最低和最高温度。但他以错误的顺序检索日期年份我得到这样的值:
数组( [00-00-0000] => 22 [00-08-2013] => 22 [01-08-0201] => 24 [01-08-0213] => 24 [01-08-2013] 。 ..
如果我使用 PHPmyAdmin 验证表中的数据,一切似乎都可以。
代码:
$query = "SELECT DATE_FORMAT(`Datum`, '%d-%m-%Y') as Datum1, min(`Temperatuur`)as minTemp ,max(`Temperatuur`)as maxTemp FROM `tableGreenhouse` GROUP BY `Datum1` ORDER BY 1";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$date = $row['Datum1'];
$Temp1 = $row['minTemp'];
$Temp2 = $row['maxTemp'];
$dataArray1[$date]=$Temp1;
$dataArray2[$date]=$Temp2;
}
}
print_r($dataArray1);
print_r($dataArray2);