php - Show different database record every 24 hours -
i building simple app html5 , php , need show different quote every day. have database table 365 quotes , authors in it, can't seem find way show different database record every 24 hours. new programming , searched whole internet answer couldn't find similar this.
so have html , php code connect database , show latest record. how can show user database row every 24 hours?
this code looks now:
<?php $con=mysql_connect('localhost','xxxx','xxxx'); if(!$con) { die ("failed connect: " . mysql_error() ) ; } mysql_select_db("xxxx",$con); $sql = "select * 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!
add column table named e.g. id
. iterate through rows in table , add values 1 365. can do:
$sql = "select * quotes id = " . date('d');
Comments
Post a Comment