php - Check specific MySQL value and print/delete recursively
one text
I want to check a single MySQL cell from a column periodically (every 30 min) and print it on localhost
in order to use this page as a browser source on OBS studio. Once the value changes, I want to delete the previous one and print the new one, so the output is only the current value of the cell.
Right now, I am able to connect to my database with index.php
, check a column, and print it once, but I'm having trouble adding an infinite loop and a way to delete the previous value once it changes. I've tried adding a while(1){}
in conjunction with sleep()
, but the page just never loads and nothing gets printed.
My code now:
<?php
include_once 'index.php';
$result = mysqli_query($conn,"SELECT username FROM realrobot_db.realrobot_dashboard");
?>
<!DOCTYPE html>
<html>
<head>
<title> Retrieve data</title>
</head>
<body>
<?php
if (mysqli_num_rows($result) > 0) {
?>
<table>
<?php
$i=0;
while($row = mysqli_fetch_array($result)) {
?>
<tr>
<td><?php echo $row["username"]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
<?php
}
else{
echo "No result found";
}
?>
</body>
</html>
Source