How to get the script to empty a MySQL table every 5 minutes?

Discussion in 'PHP' started by CuBz, May 24, 2008.

  1. #1
    If i wanted to empty a MySQL table every 5 minutes, which PHP script would work best?
     
    CuBz, May 24, 2008 IP
  2. vtida.com

    vtida.com Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You write query to delete all record, after user cron to set schedule
     
    vtida.com, May 24, 2008 IP
  3. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Explain with as much detail as possible please as i don't understand.

    What I want is to add a script to a page that will empty all contents from the table called 'jail' every 5 minutes. How would i do this?
     
    CuBz, May 24, 2008 IP
  4. vtida.com

    vtida.com Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    $sql="DELETE FOM jail";
    mysql_query($query);

    save it into file : cron.php
    If you use Linux sever, You login into Cpanel, click Cron job
    You set time to excute every 5 minute. If you need, i can help you
     
    vtida.com, May 24, 2008 IP
  5. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Well it is for a Jail page on a mafia game.

    I want to be able to put something on the script that says "All prisoners will be released in *** seconds"

    I want all prisoners to be released every 5 minutes so basically i want the table to empty every 5 minutes but i want people to be able to see how long till they get released.

    Do you get me?
     
    CuBz, May 24, 2008 IP
  6. MCJim

    MCJim Peon

    Messages:
    163
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If the users are on the same page then start a timer with flash everytime you empty the database with vtida's method. It won't be directly connected with the cron time but doing this will be much easier and will have the same effect. If the users switch through pages, simply echo out the cron time. I'm assuming that vtida's method works though; I haven't manipulated cron before.
     
    MCJim, May 24, 2008 IP