I want to select a random row from the MySQL table and keep it displayed in the browser for a 24 hour, after that, I need to get a new row the next day I try this code but the problem is when in refresh the page it gets a new row
$mysqli = new mysqli("localhost", "root", "password", "db");
$query = "SELECT * FROM table1 ORDER BY RAND() LIMIT 1;";
$stmt = $mysqli->prepare($query);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
echo $row['name'];
Aucun commentaire:
Enregistrer un commentaire