flemingmike Posted March 19, 2009 Share Posted March 19, 2009 hi, i was wondering if anyone had a code that i could have for when a database entry gets entered, it will remove itself after 3 hours? i have a page where someone creates a question and it currently takes a timestamp. i would like to put in my page where you view the questions the code to check all timestamps in the table, and remove any that are older than 3 hours. table is called 'findamatch' table is called 'timestamp' thanks. Quote Link to comment https://forums.phpfreaks.com/topic/150209-php-help/ Share on other sites More sharing options...
Maq Posted March 19, 2009 Share Posted March 19, 2009 Have another column in your DB to keep track of when it was inserted and run either a cron job or scheduled task, depending on what OS your server is on, and if it's 3 hours or older, delete it. Quote Link to comment https://forums.phpfreaks.com/topic/150209-php-help/#findComment-788826 Share on other sites More sharing options...
flemingmike Posted March 19, 2009 Author Share Posted March 19, 2009 i tried this... didnt work: $fam=mysql_query("SELECT id,clan,rules,month,day4,year,hour,min,ampm,timezone,teamid,ladder,maxbet,aim,email,yim,timestamp FROM findamatch ORDER BY timestamp"); while(list($id,$clan,$rules,$month,$day4,$year,$hour,$min,$ampm,$timezone,$teamid,$ladder,$maxbet,$aim,$email,$yim,$timestamp)=mysql_fetch_row($fam)){ $deleterow=$timestamp; mysql_query("DELETE FROM findamatch WHERE NOW() - 25 MINUTE > '$deleterow'"); Quote Link to comment https://forums.phpfreaks.com/topic/150209-php-help/#findComment-788837 Share on other sites More sharing options...
flemingmike Posted March 19, 2009 Author Share Posted March 19, 2009 this seems like it should be so simple.. am i missing something stupid? Quote Link to comment https://forums.phpfreaks.com/topic/150209-php-help/#findComment-788872 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.