Jump to content

Archived

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

Solarpitch

Deleting a record based on the system date/time?

Recommended Posts

Hey Guys ,

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..

1 day
3 days
5 days
1 week

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!

Cheers,
Gerard.

Share this post


Link to post
Share on other sites
[code]
<?php

$period = 5;  // how many days

$expiry_date = date('Y-m-d', strtotime("+$period days"));
?>
[/code]


Write the expiry date to the ad record.

To remove old records

mysql_query ("DELETE FROM ads WHERE expiry_date < CURDATE()");

Share this post


Link to post
Share on other sites

×

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.