WebCheez Posted May 30, 2011 Share Posted May 30, 2011 How would I make a script that would delete any row in a MySQL table that was more than 7 days old? Link to comment https://forums.phpfreaks.com/topic/237921-deleting-old-mysql-rows/ Share on other sites More sharing options...
mikesta707 Posted May 30, 2011 Share Posted May 30, 2011 do you have a column in your table that is a timestamp of when the row was entered? if so is it a date or datetime type? Link to comment https://forums.phpfreaks.com/topic/237921-deleting-old-mysql-rows/#findComment-1222591 Share on other sites More sharing options...
WebCheez Posted May 30, 2011 Author Share Posted May 30, 2011 Nope. *goes to create one* Link to comment https://forums.phpfreaks.com/topic/237921-deleting-old-mysql-rows/#findComment-1222602 Share on other sites More sharing options...
WebCheez Posted May 30, 2011 Author Share Posted May 30, 2011 So once I have that, what do I do? Link to comment https://forums.phpfreaks.com/topic/237921-deleting-old-mysql-rows/#findComment-1222606 Share on other sites More sharing options...
Drummin Posted May 30, 2011 Share Posted May 30, 2011 Something like this $timeoutseconds = 604 800; //get the time $timestamp = time(); $timeout = $timestamp-$timeoutseconds; $delete = mysql_query("DELETE FROM mytable WHERE timestamp<$timeout"); Link to comment https://forums.phpfreaks.com/topic/237921-deleting-old-mysql-rows/#findComment-1222613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.