dezkit Posted August 4, 2008 Share Posted August 4, 2008 i have a database and a table. the table is set up as id | name | date start | date end for example the date start is "8-4-2008" and the date end is "8-13-2008" is it possible so that on the date of 8-13-2008, the row auto deletes itself? regards Link to comment https://forums.phpfreaks.com/topic/118155-solved-mysql-auto-remove/ Share on other sites More sharing options...
Jabop Posted August 4, 2008 Share Posted August 4, 2008 Set up a cron job to execute a php script that will delete the row if the current date matches the end date column data Link to comment https://forums.phpfreaks.com/topic/118155-solved-mysql-auto-remove/#findComment-607898 Share on other sites More sharing options...
dezkit Posted August 4, 2008 Author Share Posted August 4, 2008 how? Link to comment https://forums.phpfreaks.com/topic/118155-solved-mysql-auto-remove/#findComment-607923 Share on other sites More sharing options...
.josh Posted August 4, 2008 Share Posted August 4, 2008 Depends on your host as to how to setup a cron job, or if you're even allowed to. I suggest you talk to them about that. But if you have cpanel there is an icon for setting up a cron job (again, assuming your hosting plan allows cron jobs). Follow the instructions. As far as the script you want the cron job to run every x amount of time, it can be something as simple as <?php $conn = mysql_connect('localhost','dbusername','dbpass'); $db = mysql_select_db('dbname',$conn); mysql_query("delete from table where date_end > now()", $conn); ?> Link to comment https://forums.phpfreaks.com/topic/118155-solved-mysql-auto-remove/#findComment-607933 Share on other sites More sharing options...
dezkit Posted August 4, 2008 Author Share Posted August 4, 2008 thanksss Link to comment https://forums.phpfreaks.com/topic/118155-solved-mysql-auto-remove/#findComment-607960 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.