I have MySQL database in LAMP server, Database is called coe and table is called pulses. the columns are:
Pulse | int
id | int
time | timestamp - current timestamp
I want select all values in pulse and then choose the max value with last 1 minute from current time. After that, I want to delete all rows in table with also last 1 minute.
I tried this code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "testdb";
$mysqli = mysqli_connect ($servername, $username, $password, $dbname);
$res = mysqli_query($mysqli, "SELECT MAX(pulse) as pulse FROM pulses where pulse BETWEEN 400 and 500 AND time > UNIX_TIMESTAMP() - 60");
$row = mysqli_fetch_assoc($res);
echo $row['pulse'];
$DeleteQuery = mysql_query('DELETE FROM pulses WHERE time > (UNIX_TIMESTAMP() - 60)');
?>
The code section of connection with database and select data with max value that work and it is not deleting the rows. i tried a lot but without success. please help