Jump to content


Photo

Auto-delete code


  • Please log in to reply
4 replies to this topic

#1 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 May 2006 - 07:01 AM

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 :)


#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 02 May 2006 - 08:15 AM

What do you mean by auto-delete code you explain a but more about what you are trying to do.

#3 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 02 May 2006 - 09:20 AM

[!--quoteo(post=370487:date=May 2 2006, 01:15 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ May 2 2006, 01:15 AM) View Post[/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.

#4 tjhilder

tjhilder
  • Members
  • PipPipPip
  • Advanced Member
  • 136 posts
  • LocationKent, UK

Posted 02 May 2006 - 11:54 AM

[!--quoteo(post=370501:date=May 2 2006, 10:20 AM:name=9911782)--][div class=\'quotetop\']QUOTE(9911782 @ May 2 2006, 10:20 AM) View Post[/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..

$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;
}

date's column would be like this in mysql

`date` datetime NOT NULL,

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.

#5 9911782

9911782
  • Members
  • PipPipPip
  • Advanced Member
  • 39 posts

Posted 24 July 2006 - 09:51 AM

Hi
thank you for your help.
Ur example is working for me, its exaclty what I've been looking for...

thanka milion :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users