Solarpitch Posted October 29, 2006 Share Posted October 29, 2006 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 day3 days5 days1 weekIs 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. Link to comment https://forums.phpfreaks.com/topic/25479-deleting-a-record-based-on-the-system-datetime/ Share on other sites More sharing options...
Barand Posted October 29, 2006 Share Posted October 29, 2006 [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 recordsmysql_query ("DELETE FROM ads WHERE expiry_date < CURDATE()"); Link to comment https://forums.phpfreaks.com/topic/25479-deleting-a-record-based-on-the-system-datetime/#findComment-116253 Share on other sites More sharing options...
Solarpitch Posted October 29, 2006 Author Share Posted October 29, 2006 Thats simple huh! lol . . brilliant . . thanks a mill! :) Link to comment https://forums.phpfreaks.com/topic/25479-deleting-a-record-based-on-the-system-datetime/#findComment-116255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.