Please Help Me

Discussion in 'PHP' started by haveseo, Jul 2, 2010.

  1. #1
    Hello
    Please help me.
    I want to empty some tables of one of my databases every 1 hour.
    Now i want to create a php file and set cronjob for it to do it.
    But i dont know how to write codes for php file.
    I want it:
    For example i want that table1,table2 and table3 from database1 to be emptied every 1 hour. Please write php code for me.
    Thanks in advance.
     
    haveseo, Jul 2, 2010 IP
  2. Silent Media

    Silent Media Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    mysql_query("TRUNCATE TABLE table") or die(mysql_error());
    PHP:
     
    Silent Media, Jul 2, 2010 IP
  3. haveseo

    haveseo Well-Known Member

    Messages:
    995
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Thanks a lot. But can you please write php code according to my example?
    table1,table2 and table3 from database1 to be emptied
     
    haveseo, Jul 2, 2010 IP
  4. haveseo

    haveseo Well-Known Member

    Messages:
    995
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    103
    #4
    Any one can't help me more?
    I am waiting for experts to help me.
     
    haveseo, Jul 3, 2010 IP
  5. webal

    webal Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you can create array for tabel names

    $tables=array("table1","table2","table3",...);
    foreach ($tables as $table) {
    mysql_query("TRUNCATE TABLE $table") or die(mysql_error());
    }
     
    webal, Jul 3, 2010 IP