Jump to content

Updating certain records at the start of the day


adambedford

Recommended Posts

I've got a database with several fields including 'Renewal_date' and 'Visible'. When inserting records I calculate the renewal date based upon the current date and a couple of other things and I set 'Visible' to 'Y'.

 

My queries throughout the site then filter out the records and display only those with 'Visible' set to 'Y'.

 

I need a way to update the records each day so that any expired records then get visible set to 'N'. I'm thinking of using a crontab to execute the script once a day (at midnight perhaps) so that everything is as accurate as possible.

 

My question is: how would I go about updating the records that have passed the 'Renewal_date'. I guess I need a checker of some sort to check whether they have expired or not and then MySQL to update the records?

 

Would I need to use a foreach command or a do while?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.