Search code examples
phprefresh

How to show/select Quote Of The Day


I have a database with lots of quote's and I want to create a "Quote of the Day" page. The basic idea is to fetch all the quotes from the database, place this in an array and echo the quote at a random index number in the array.

That is the basic idea which is very to implement and which I have of course covered so far. The problem is, every time the page is refreshed, a new quote will pop up. This is not what I want.

I want the page to refresh the quote ONLY at 0:00 (or another time, but that is not the point).

Can anybody please point me in the right direction?


Solution

  • This sounds overly complex. The normal way to do something like this would be

    • Store the quotes in the database; give each row a date
    • On every request, fetch the quote of the current day from the database and display it.

    If you don't want to specify a date in the database, you could also hard-code a start date in your script (like, say, today's date) and then fetch the quote accordingly - so today, you'd fetch the first row in your database; tomorrow, the second, and so on.