SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Delete code

  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Delete code

    Hi Guys,

    what im trying to do here is if customers dont proceed with there online orders i delete them after 24 hours! i have this so far:

    PHP Code:
    <?php
     
    // Auto delete the users cart 24 hours after making selection
     
    $q_times "SELECT `date` FROM `fcp_orders`";
     
    $r_times mysql_query($q_times);
     
    $a_times mysql_fetch_array($r_times);
       
    $times $a_times['date'];
       
     
    $time $times;
     
    $next date('Y-m-d H:i:s'strtotime("$time + 24 hours"));
     
     
    // delete query
     
    $q_delete mysql_query("DELETE FROM `fcp_orders` WHERE `date` => $next");
    ?>
    does this look ok?

    cheers

    Graham

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can do this with sql
    Code:
    DELETE FROM `fcp_orders` WHERE `date` > CURRENT_TIMESTAMP + interval 1 day

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    crmalibu, you want to delete orders that were made tomorrow or later?

    whoa!!
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops lol

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol hey guys! sorry i took so long getting back.

    the above code doesnt work! im not sure what i have done wrong exactly any other ideas?

    cheers guys

    Graham

  6. #6
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    DELETE FROM fcp_orders WHERE date <= date_sub( now( ) , INTERVAL 24 HOUR )
    my mobile portal
    ghiris.ro

  7. #7
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks ernie appreciate that

    Graham


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
  •