Re: How do I delete a composite key?
| From: | Richard Lynch | Date: | Sun, 26 Aug 2007 21:53:26 +0000 |
| Subject: | Re: How do I delete a composite key? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261304@lists.php.net to get a copy of this message | ||
On Sun, August 26, 2007 2:05 pm, Stut wrote:
> nitrox . wrote:
>> Im trying to delete a composite key but cannot figure out the proper
>> format. Would somebody tell me where im messing up? I have an url
>> that
>> is supposed to send the member id and game id to a delete query. And
>> the
>> delete query is supposed to grab the id's based on type.
>>
>> This is the link:
>>
>> <a
>>
>> href=\"member_commit.php?action=remove&type=Member&id={$record->Member_id}&gametype=Game&id={$record->Game_id}\">[GAME
>> REMOVAL]</a></td>\n";
> <snip>
>> $sql = "DELETE
>> FROM xsm_membergames
>> WHERE Member_id = '" .
>> mysql_real_escape_string((int)$_GET['id']) . " .
>> AND Game_id = '" . mysql_real_escape_string((int)$_GET['id']) .
>> "'";
>
> Your URL contains 2 instances of a GET variable named, which you then
> use in the SQL query. In this instance $_GET['id'] will contain just
> the
> Game_id. Change the name of one or both IDs and you should be ok.
Another possiblity, if you are trying to write this more generically,
would be to use:
?id[game]=$record->Game_id&id[Member]=$record->Member_id
$_GET['id'] will then be an array that looks something like this:
array('game' => 42, 'member' => 17);
You would then iterate through $_GET['id'] and show all the factors
that are going into the query/delete.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?