Re: How do I delete a composite key?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux