Php MySQL将时间范围限制为10
我试图创建一个时间范围内的温度读数数组,但将其限制为每10个读数只能读取1个读数。你能帮我把这个函数添加到下面的代码中吗?:)Php MySQL将时间范围限制为10,php,mysql,raspberry-pi,intervals,Php,Mysql,Raspberry Pi,Intervals,我试图创建一个时间范围内的温度读数数组,但将其限制为每10个读数只能读取1个读数。你能帮我把这个函数添加到下面的代码中吗?:) $dataArray=array(); $sql=“从$sensorID中选择*其中时间>日期(现在(),间隔$timeDuration HOUR)和时间如果我理解正确,您想每10行显示一次吗 $i=0; if ($result) { while ( $row = mysql_fetch_array($result)) { if($i % 10
$dataArray=array();
$sql=“从$sensorID中选择*其中时间>日期(现在(),间隔$timeDuration HOUR)和时间如果我理解正确,您想每10行显示一次吗
$i=0;
if ($result) {
while (
$row = mysql_fetch_array($result)) {
if($i % 10 == 0)
{
$time=$row["Time"];
$temperature=$row["Temp"];
$dataArray[$time]=$temperature;
}
$i++;
}}
谢谢迈克尔O
它现在对我起作用了:D
$i=0;
if ($result) {
while (
$row = mysql_fetch_array($result)) {
if($i % 10 == 0)
{
$time=$row["Time"];
$temperature=$row["Temp"];
$dataArray[$time]=$temperature;
}
$i++;
}}
编辑您的问题并提供示例数据和所需结果。请停止使用PHP不推荐的mysql API是的,我需要每10行获取一次,我已经尝试了您的代码,但它对我不起作用:-/
$i=0;
if ($result) {
while (
$row = mysql_fetch_array($result)) {
if($i % 10 == 0)
{
$time=$row["Time"];
$temperature=$row["Temp"];
$dataArray[$time]=$temperature;
}
$i++;
}}