Jump to content

Archived

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

9911782

Auto-delete code

Recommended Posts

Hi All

Im very new in php. Can somebody send me the link of website where I could get the tutorial that will help me to understand on how to code the Auto-delete code in php?

Your help is highly appreciated.

thank you :)

Share this post


Link to post
Share on other sites
What do you mean by auto-delete code you explain a but more about what you are trying to do.

Share this post


Link to post
Share on other sites
[!--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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Hi
thank you for your help.
Ur example is working for me, its exaclty what I've been looking for...

thanka milion :)

Share this post


Link to post
Share on other sites

×

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.