Deleting a record based on the system date/time?
Posted 29 October 2006 - 01:25 PM
I have an application that involeves user's uploading an add to sell a product. The user gets to select whether they want the add to run online for..
Is there a way or some code that I can use that automically removes the add from the database, based on the system date and time?
So if user selects 1 day . . 24 hours from the time it was uploaded it will be automatically deleted or better still . . deleted and stored in an admin table!
Posted 29 October 2006 - 01:54 PM
<?php $period = 5; // how many days $expiry_date = date('Y-m-d', strtotime("+$period days")); ?>
Write the expiry date to the ad record.
To remove old records
mysql_query ("DELETE FROM ads WHERE expiry_date < CURDATE()");
Donations gratefully received
|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts
Posted 29 October 2006 - 01:58 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users