First of all, grab the tip count, using COUNT() on the table. To make sure you can rotate over all the tips, you'll need some sort of day count.
You can use (time()/(60*60*24)) to get the number of days since 1st January 1970. Take that modulo the number of tips, so you can get a tip 'number' (ranging from 0 to COUNT(*)-1).
However, you can't use 'WHERE ID=$something', because IDs are not necessarily consecutive (e.g. if you delete a record, its ID becomes free). You'll have to order by some field, like ID, and get the nth record from the list, so your query should look like this:
Code:
SELECT Tips.*
FROM Tips
ORDER BY Tips.ID, LIMIT ???, 1
Once you get that tip, you can output it. Here's what your PHP tip code should look like this:
Code:
<?
// Stuff here...
$tipcountquery = mysql_query("SELECT COUNT(Tips.*) AS TipCount " .
"FROM Tips");
$tipcount = mysql_fetch_array($tipcountquery)['TipCount'];
$tipnumber = (time()/(60*60*24)) % $tipcount;
$tipquery = mysql_query("SELECT Tips.* " .
"FROM Tips " .
"ORDER BY Tips.ID LIMIT $tipnumber, 1");
$tipcontent = mysql_fetch_array($tipquery);
// Stuff here...
?>
Cheers,
Fabio Dias
Bookmarks