I am building a simple app with HTML5 and PHP and I need to show a different quote every day. So I have a database table with all the 365 quotes and authors in it, but I can't seem to find a way to show a different database record every 24 hours. I am fairly new to programming and searched the whole internet for an answer but couldn't find anything similar to this.
So I have my html and php code to connect to the database and show the latest record. How can I show the user another database row every 24 hours?
This is what my code looks like now:
<?php
$con=mysql_connect('localhost','xxxx','xxxx');
if(!$con)
{
die ("Failed to connect: " . mysql_error() ) ;
}
mysql_select_db("xxxx",$con);
$sql = "SELECT * FROM quotes LIMIT 1" ;
$myData=mysql_query($sql,$con) ;
while($record = mysql_fetch_array($myData)) {
echo "<h1>" . $record['quote'] . "</h1>";
echo "<br><p> - " . $record['author'] . " - </p>";
}
mysql_close($con);
?>
Thanks in advance guys!