I have a project that requires me to develop a website say like ebay or craigslist where users will be uploading ads and items for sale or maybe advertisement purposes. I want the users to have an option of duration that how long they would want their items to remain on the website. Let say the options are 7 days, 15 days and 30 days, if a user selects 15 days for his/her item to remain on the website, I want a simple and reliable solution that automatically deactivates or removes this specific item from the database after 15 days at exactly the same time of upload. (Must be accurate up to minutes and even seconds). Since I love php so much, I would also love if the answer is simply possible in php. Anyway, if there is another solution more reliable let me know it. I have been considering setting a $_SESSION[] and then destroying it after the time limit but I have this feeling that it may not be the best approach available. Whatever,,,,, Please help me out, Please explain. Thank you in advance.
Asked
Active
Viewed 422 times
1 Answers
1
This may help you.
DELETE FROM table WHERE delete_date >= (CURDATE() - INTERVAL 7 DAY);

Techy
- 2,626
- 7
- 41
- 88
-
but that only executes when it's requested. what if this request is made like 10 seconds, or maybe 1 minute or one day after the exact time limit? As I mentioned in the description of the question, It must be automatic. as soon as the time (the second) of expiry reaches, the item must be deactivated. I don't think this could be accomplished alone by php. – zia-khan Apr 13 '14 at 11:17
-
I understand your issue.I am not sure about this.You please check You can schedule events in mysql. Have a look on this http://dev.mysql.com/doc/refman/5.1/en/events.html – Techy Apr 13 '14 at 11:26
-
check this also http://stackoverflow.com/questions/9865393/how-to-delete-mysql-row-after-time-passes – Techy Apr 13 '14 at 11:28