dezkit Posted October 27, 2009 Share Posted October 27, 2009 hello, i have a field in my mysql called date, i want to do so that when the current date is equal to the date in the field, the row will be automatically deleted, how do i do this? the date is like "j/d/y" thank you Quote Link to comment https://forums.phpfreaks.com/topic/179134-remove-row-mysql/ Share on other sites More sharing options...
Garethp Posted October 27, 2009 Share Posted October 27, 2009 $date = date("j/d/y"); // Use http://php.net/manual/en/function.date.php to make it the right format mysql_query("DELETE FROM `tablename` WHERE `rowname`='$date'); Quote Link to comment https://forums.phpfreaks.com/topic/179134-remove-row-mysql/#findComment-945118 Share on other sites More sharing options...
joel24 Posted October 27, 2009 Share Posted October 27, 2009 ... do you want it removed when something in the database is updated? or when a page is viewed? or automatically at 12:01am? Quote Link to comment https://forums.phpfreaks.com/topic/179134-remove-row-mysql/#findComment-945119 Share on other sites More sharing options...
dezkit Posted October 27, 2009 Author Share Posted October 27, 2009 ... do you want it removed when something in the database is updated? or when a page is viewed? or automatically at 12:01am? automatically at 12:01am thanks Quote Link to comment https://forums.phpfreaks.com/topic/179134-remove-row-mysql/#findComment-945120 Share on other sites More sharing options...
joel24 Posted October 27, 2009 Share Posted October 27, 2009 then you can use the mysql event feature if your using mysql 5.1.6 or greater http://dev.mysql.com/tech-resources/articles/event-feature.html or you can set up a cronjob which will run a script automatically at 12.01am every morning... http://articles.sitepoint.com/article/introducing-cron Quote Link to comment https://forums.phpfreaks.com/topic/179134-remove-row-mysql/#findComment-945121 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.