How would I create a PHP script that deletes rows out of a database every day?

Discussion in 'PHP' started by Imozeb, Apr 23, 2010.

  1. #1
    I want to create a PHP script that runs automaticly every day at a specific time that deletes data from a specific column in a database. How would I do this? I know how to delete data from a column but I do not know how to make the script run on the server automaticly.

    Also how would I select all the rows from a database where 'name' == 'bob' and order that data by increasing 'date' where the 'date' is passed through a MySQL command (DATE_FORMAT)?

    Thanks!
     
    Imozeb, Apr 23, 2010 IP
  2. mrdayak

    mrdayak Peon

    Messages:
    82
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you can using CRON JOB on your server to run php script automatically at a specific time everyday.

    D
     
    mrdayak, Apr 23, 2010 IP
  3. taduyducvn

    taduyducvn Greenhorn

    Messages:
    81
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    Or integrate it into your webpage using a require(); that require a php that run a function everytime someone visit, check for the datetime (put it a range of date time, and it's applicable for large site only), prefer the cronjob.

    Also another way is to use a long running script that can still run and sleep even if you closed the page (dangerous though)

    Use the cronjob on your webhost manager, everyone have that.
     
    taduyducvn, Apr 23, 2010 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Okay. Thanks for the info!
     
    Imozeb, Apr 24, 2010 IP
  5. mukeshvariya34

    mukeshvariya34 Peon

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hello,

    I prefere to use cron job - very fine and good one...
     
    mukeshvariya34, Apr 25, 2010 IP