A couple of thoughts:
As you want to cycle through the list rather than randomly (with repetition) picking from the list, have you considered storing the last CD shown details in the DB?
If each CD has a sequential ID then each week (or day) you increment the number which will determine what CD is shown. If the incremented CD id exceeds the highest id in the DB, restart back at the first id.
Just incrementing the ID is not a good idea. It does not allow for the flexibility required if you suddenly delete a CD in the middle. So it'd be better doing something like "SELECT * FROM cds WHERE `CDid`>'$LastCDid' ". Then obviously you'd need to check if the last shown was the last in the base, you'd get 0 rows. But this can be circumvented by just checking the number of rows returned, and if the rowcount is < 1, simply do a new SELECT with CDid > 0.
You could also include a column (or two) in the CD info table to record when it was last displayed and check that this is > 29 days ago.
I agree that this would be the easiest way. On every display you do an update to store the date, then on each page load just calculate how long ago the CD show must've been shown last.
What about cookies? Each visitor could then have their own 'cycle' through the list.
This is a per need basis. With the "last shown date" you don't need the cookies.
-- Rene Brehmer aka Metalbunny
If your life was a dream, would you wake up from a nightmare, dripping of sweat, hoping it was over? Or would you wake up happy and pleased, ready to take on the day with a smile?
http://metalbunny.net/ References, tools, and other useful stuff... Check out the new Metalbunny forums at http://forums.metalbunny.net/
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php