PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Anyway, on to my question. I'm creating a PHP/SQL based classified ads page and I'd like each ad to have a shelf life of a certain amount of weeks; after which they would just be purged.
Is there a good way to do this? is this all controlled via mysql?
You use a MySQL DB to store the dates those ads were created.
When loading the ads on your website (or use a cron job) you check whether their date has expired and then you can either do:
A) Delete the ads from the DB (or wherever you stored them). This option could have a big impact on performance if you'll use it when loading them on your website. It's better for cron jobs.
B) Choose to not view them (skip these ads and move on to the next). This option is better if you're going to perform it when loading the website, and useless if you're going to use cron jobs.
pilau wrote:You use a MySQL DB to store the dates those ads were created.
When loading the ads on your website (or use a cron job) you check whether their date has expired and then you can either do:
A) Delete the ads from the DB (or wherever you stored them). This option could have a big impact on performance if you'll use it when loading them on your website. It's better for cron jobs.
B) Choose to not view them (skip these ads and move on to the next). This option is better if you're going to perform it when loading the website, and useless if you're going to use cron jobs.
I like the idea of not displaying them if they are past a certain date, and the admin would just go in and clean up if they wanted to; but, can you give me more info on "cron jobs"?