Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    delete two ids from two tabels with one click

    Hello

    How do u delete two IDs from two tabels in on click .. i tried this , but it only delete ID 1 from tabel one and no change to id in tabel two.

    PHP Code:
    $sql "DELETE FROM "._TABLE1." and "._TABLE2." WHERE id1 and id2 = ".intval($_GET['id'] ); 
    what i try to do is when delete the ID from tabel 1 to also delete the same id from tabel 2.

  • #2
    New Coder
    Join Date
    Apr 2008
    Location
    Blagoevgrad, Bulgaria
    Posts
    47
    Thanks
    0
    Thanked 8 Times in 8 Posts
    Try like this:
    PHP Code:
    $sql "DELETE FROM "._TABLE1.", "._TABLE2." WHERE "._TABLE1.".id1 = '" intval($_GET['id']) . "' AND "._TABLE2.".id2 = '" intval($_GET['id']) . "'"

  • Users who have thanked er4o for this post:

    ajloun (12-07-2009)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    thank you but did not delete any

  • #4
    New Coder
    Join Date
    Apr 2008
    Location
    Blagoevgrad, Bulgaria
    Posts
    47
    Thanks
    0
    Thanked 8 Times in 8 Posts
    Ahh yes, just tested it at my local host. Got working query:

    PHP Code:
    if ($_GET['id']) {
    $id intval($_GET['id']);
    $sql "DELETE "._TABLE1.".*, "._TABLE2.".* FROM "._TABLE1.", "._TABLE2." WHERE "._TABLE1.".id1 = '$id' AND "._TABLE2.".id2 = '$id'";
    mysql_query($sql);


  • Users who have thanked er4o for this post:

    ajloun (12-07-2009)

  • #5
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    er4o that was perfect .. Sorry for delay answering .. i went sleep ..


  •  

    Posting Permissions

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