Forum Moderators: coopster

Message Too Old, No Replies

My insert creates one row! (unwnated)

result= insert goes to the unwanted new row!

         

henry0

10:20 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I cannot figure how to fix it
That snippet should be used to grab an ID which it does fine
Then insert that ID in a col named "member_web_address"

As mentioned it does get the ID and insert it
But not on the row where from the ID was taken
It does insert it on a new row created by the insert action
Which due to the auto increment creates a new ID etc...

How can I keep the original row and pass its ID # to the "member_web_address" col in the very same row

thanks

<?

$query = "select id from templates where username= '$username' and page= '$page' ";
$result= mysql_query ($query);
while($query_data=mysql_fetch_array($result))
{
$member_web_address=($query_data["id"]);
}
$query = "select id from templates where username= '$username' and page= '$page' ";
$result= mysql_query("insert into templates (member_web_address) values ('$member_web_address')");
?>

jatar_k

10:44 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you've got your wires crossed a bit.

insert - inserts new rows into an existing table
UPDATE [mysql.com] - updates columns in existing table rows with new values. So..

update table templates set member_web_address = '$member_web_address' where .....

henry0

11:05 pm on Jan 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ooopppsss!
seems to be the only answer :)

thanks

never understood why I do focus on finding a tiny needle
when I should look for a sword

actually I should use it to crak open my brain and rewire!