This isn’t a programming specific question but more of a general question:
I have several quotes in my database. I can add more quotes whenever I like, but the idea is this:
Everyday a new quote is displayed and the day after that the next quote is showed. When the “limit” of the quotes is reached the first quote is displayed, allowing you to always have a quote on your website.
How would I do this?
I know there needs to be a check like “IF quote was displayed yesterday, show new quote and IF yesterdays quote is also the latest in the database start with the first quote”. I absolutely have no idea how to start with this, so a little help is much appreciated!
I’m using PHP and MySQL.
or use pdo instead of mysql’s old functions, but you get the point…
EDIT
just to explain – $q will always progress by 1 from the previous day. $q % $n will be the offest, when fetching the quote tuple from the table. we’ll order by ID to keep the results in the same order, ID will be the auto incremented primary key. this should do the trick.
Of course if you want performance you can save it into a file and run a once a day to update it, so you will not need to query the database for it.
EDIT
fixed $q