Bobafart
11-17-2008, 04:40 PM
Hi,
I have a number of data items in a table called "mytable"
each item has a column named "lastDateDisplayed" which is a UNIX TIMESTAMP. Each time the image is displayed (a random image is chosen every 24 hours via crontab) I update the "lastDateDisplayed" column with the current date the image is being displayed
I don't want an image to be randomly displayed within a 1 month interval. It is suffienct to assume that 1 month = 30 days.. it doesn't need to be exactly the number of days in the current month.
so, how do I SELECT a random image from mytable that hasn't been displayed for a month?
A month in UNIX TIME would be:
1 month (assuming 30 days) = 30 * 24 * 60 * 60 = 2592000
SELECT id FROM mytable WHERE lastDateDisplayed > 2592000 ORDER BY random() LIMIT 1
... ?? doens't work...
I have a number of data items in a table called "mytable"
each item has a column named "lastDateDisplayed" which is a UNIX TIMESTAMP. Each time the image is displayed (a random image is chosen every 24 hours via crontab) I update the "lastDateDisplayed" column with the current date the image is being displayed
I don't want an image to be randomly displayed within a 1 month interval. It is suffienct to assume that 1 month = 30 days.. it doesn't need to be exactly the number of days in the current month.
so, how do I SELECT a random image from mytable that hasn't been displayed for a month?
A month in UNIX TIME would be:
1 month (assuming 30 days) = 30 * 24 * 60 * 60 = 2592000
SELECT id FROM mytable WHERE lastDateDisplayed > 2592000 ORDER BY random() LIMIT 1
... ?? doens't work...