Jump to content

Auto-delete code


9911782

Recommended Posts

[!--quoteo(post=370487:date=May 2 2006, 01:15 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 2 2006, 01:15 AM) [snapback]370487[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What do you mean by auto-delete code you explain a but more about what you are trying to do.
[/quote]

I have a events table that stores all the event per school. They way me to have a facility that will provide for an auto-delete in respect of advertisement of events exceeding 3 months publication time.

So, I need someone to help with tutorial or a code to do this.

I hope Im clear.
Link to comment
https://forums.phpfreaks.com/topic/8871-auto-delete-code/#findComment-32561
Share on other sites

[!--quoteo(post=370501:date=May 2 2006, 10:20 AM:name=9911782)--][div class=\'quotetop\']QUOTE(9911782 @ May 2 2006, 10:20 AM) [snapback]370501[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I have a events table that stores all the event per school.
[/quote]
I'm thinking you mean a mysql table? if so possibly a query like this..

[code]$autodelete_date = date('Y-m-d H:i:s');

$autodelete_query = "DELETE FROM events_table WHERE (date <= '" . $autodelete_date . "')"; // deletes anything before now.
if (!$autodelete_result = mysql_query($autodelete_query)) // if problem, display error.
{
    echo "nothing deleted because : " . mysql_error() . " the query was: " . $autodelete_query;
}[/code]

date's column would be like this in mysql

[code]`date` datetime NOT NULL,[/code]

this is untested btw, maybe someone might have a better idea or maybe an edit of that code, i dunno. but it should work if you have the table set right.

hope that helps.
Link to comment
https://forums.phpfreaks.com/topic/8871-auto-delete-code/#findComment-32585
Share on other sites

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.