I am wanting to develop a PHP script that can be used with a Cronjob to delete records in a database that are older than 60 days. I am relatively new to PHP and MySQL so I’m not sure where to start. Can anyone help me write the script?
Derek, you’ve got a couple of things going on here: 1) you need a php script to delete the records, then 2) you need to schedule it with cron (or some other means).
You’ll need a field in your table to store the age of the record. Do you have that? If not, you’ll need to modify your database structure and enter that data.
If it were me, I’d develop the script first, test it, and then when I was sure it was working, I’d automate it. You can use Windows Task Scheduler on a local PC (ie, at your place). Or, you can create a cron job via your control panel.