使用PHP删除SQL操作

时间:2015-05-15 08:59:59

标签: php mysql sql arrays

我在PHP语言中遇到SQL DELETE问题。我不知道删除sql操作的问题在哪里。 你能帮帮我吗?

代码是:

$query = mysqli_query($connessione, "SELECT * FROM (SELECT date, time, temperature FROM streamcopy WHERE moteid = '".$sensor."' AND CONCAT(DATE, ' ',TIME) BETWEEN '".$i."' AND '".$f."' ORDER BY date DESC, time DESC) AS tab ORDER BY date, time");

$n = 0;
$m = 0;
while($row = mysqli_fetch_array($query)){
    if($n == 0){
        $num = $row['temperature']; //OK
        $n = $n+1;
    }
    else{
        $temp[$m] = $row; //OK
        if(abs($num - $temp[$m]['temperature'])<0.5){ //OK
            $queryFIXED = mysqli_query($connessione, "DELETE FROM streamcopy WHERE moteid = '".$sensor."' AND temperature = '".$temp[$m]['temperature']."' AND date = '".$temp[$m]['date']."' AND time = '".$temp[$m]['time']."')"); /* elimina dati di temperatura k vicini */
            $n = $n+1;
            $m = $m+1;
        }
        else{
            $num = $temp[$m]['temperature'];
            $n = $n+1;
            $m = $m+1;
        }
    }
}

0 个答案:

没有答案