arduino connect to mysql and compare

hi, i'm using "wiattend" (GitHub - abobija/wiattend: RFID Attendance System realized using MFRC522 and ESP32) from the base and I'm trying to adapt my own needs, but I don't know if it's possible.
I want to confirm lunch only if they have logs in the last 8 hours, how can I do it?

(I use this base to manage attendance and give clothes for the workday, but I want to authorize only if they have worked in the last 8 hours, these are two different locations!)

for now, i do this:

<?php
$servername = "localhost";
$database = "wiattend";
$username = "root";
$password = "";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);
// Check connection
if (!$conn) {
     die("Connection failed: " . mysqli_connect_error());
}


$last = "SELECT *, DATE_FORMAT(NOW(), '%H:%i') as time  FROM log WHERE tag_id=3 AND time > DATE_SUB(CURDATE(), INTERVAL 1 HOUR)";

$result = $conn->query($last);

if ($result->num_rows > 0) {
   // output data of each row
   while($row = $result->fetch_assoc()) {
       echo "id: " . $row["tag_id"]. " - Hora: " . $row["time"].  "
";
   }
} else {
   echo "0 results";
}
mysqli_close($conn);
?>