Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-07-2009, 06:04 AM   PM User | #1
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
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.
ajloun is offline   Reply With Quote
Old 12-07-2009, 06:58 AM   PM User | #2
er4o
New Coder

 
Join Date: Apr 2008
Location: Blagoevgrad, Bulgaria
Posts: 47
Thanks: 0
Thanked 8 Times in 8 Posts
er4o is an unknown quantity at this point
Try like this:
PHP Code:
$sql "DELETE FROM "._TABLE1.", "._TABLE2." WHERE "._TABLE1.".id1 = '" intval($_GET['id']) . "' AND "._TABLE2.".id2 = '" intval($_GET['id']) . "'"
er4o is offline   Reply With Quote
Users who have thanked er4o for this post:
ajloun (12-07-2009)
Old 12-07-2009, 07:28 AM   PM User | #3
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
thank you but did not delete any
ajloun is offline   Reply With Quote
Old 12-07-2009, 09:39 AM   PM User | #4
er4o
New Coder

 
Join Date: Apr 2008
Location: Blagoevgrad, Bulgaria
Posts: 47
Thanks: 0
Thanked 8 Times in 8 Posts
er4o is an unknown quantity at this point
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);

er4o is offline   Reply With Quote
Users who have thanked er4o for this post:
ajloun (12-07-2009)
Old 12-07-2009, 07:53 PM   PM User | #5
ajloun
Regular Coder

 
Join Date: Aug 2009
Posts: 215
Thanks: 74
Thanked 0 Times in 0 Posts
ajloun has a little shameless behaviour in the past
er4o that was perfect .. Sorry for delay answering .. i went sleep ..
ajloun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:22 AM.


Advertisement
Log in to turn off these ads.