View Single Post
Old 06-27-2007   #5 (permalink)
notjustgraphics
Rusty Bio-Hazard!
 
notjustgraphics's Avatar
 
Join Date: Sep 2006
Location: Toronto, Ontario, Canada
Posts: 1,159

Send a message via MSN to notjustgraphics
Ok...

Lets say you have 365 records in your database, each with a numberic field numbered 0 to 365....

If you create an if statement like this:
PHP Code:
$todaysdate date("z");
$query="select * from tablename where id = " $todaysdate
In the code above, replace tablename with the name of your table... I've assumed you've already established a connection to your database.

What this is selecting one record from the database that corresponds with the numerical day of the year (Ie: New Years day, the first day of the year, is 1 and New Years Eve, the last day of the year, is 365)

Now, this method is simple, but requires you to have 1 and only one entry for each day of the year.... if you have say 183 entries (half the days in a year) you could divide the $todaysdate by 2 to get your id number, but this would cause the same record to be displayed for 48 hours.

The other method, which requires an update command, is to set a 'displayed' flag that marks a record as already used until the entire database is marked as 'displayed' then you have to clear all the flags, and begin the process again...

Are you comfortable coding in PHP?

Mike.
__________________
notjustgraphics is offline