SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Autodelete

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Autodelete

    Hi All

    Im currently working on PHP project. How do I go about doing the Autodelete.Can somebody send me the tutorial where I coul learn on how perform an autodelete on my website.

    Ok! here is the scenario, I have to post a notice to my noticeboard, this post should be there for 3 months after that it should be deleted/archived.

    Pls help me

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2003
    Location
    Melbourne, Australia
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since this question is about:
    1. Saving posts with a timestamp
    2. Checking the timestamp against the current time (to work out age)
    3. Issuing commands to the database or filesystem to delete posts
    ...it's most appropriate for the Basic PHP forum.

    Edit: Oh, it's been moved. Thanks, moderators.
    Zealotry is contingent upon 100 posts and addiction 200?

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    auricle's got the basics for ya. In your database table containing the posts, you should store the date and time of the post (a datetime field or timestamp). Then a single database query can tell you what posts are 3 months old, so that you can delete or archive them.

  4. #4
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's basically what's sometimes called Garbage Collection. I use that same process on a website I created to make sure inactive users are logged off. It's a very fast script that runs on every PHP page that uses a database connection (which is most of them).

    There's no point in trying to give you code - the process is already outlined above.
    Ian Anderson
    www.siteguru.co.uk

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you very much for your reply.

    dont u have an example where I could be able to reference to?

    thank you

  6. #6
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    SELECT FROM posts WHERE TO_DAYS(CURDATE()) - TO_DAYS(post_date) > 90 
    What else do you want an example of?

  7. #7
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     DELETE FROM posts WHERE TO_DAYS(CURDATE()) - TO_DAYS(post_date) > 90 
    Ian Anderson
    www.siteguru.co.uk

  8. #8
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok! thank you very much for your response.

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank for your eample

  10. #10
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you for your example


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •