I want to display 1 random record from a database based on the week.
I need to determine if it’s a new, and if it is a new week, then select the record and display the new record.
I’m thinking I can just use a single day of the week to generate the new record, either way will work.
I’m really having a hard time conceptualizing how I’ll store the record id and not select a new one when someone visits again the same day or refreshes the page.
Any ideas? Let me know if I wasn’t clear enough.
Also, I don’t have access to cron jobs as it’s shared hosting.
Create a table containing the id of the row you want to display and a datetime/timestamp column that says when that row was inserted. Then all you have to do is to update the id if it is more than week since it was inserted. Unfortunately you would have to do this check for every request. If you don’t want that you could create a cron-job that runs once a week and updates the table.