overwriting new information in a table

From: Date: Sun, 02 Dec 2001 21:27:25 +0000
Subject: overwriting new information in a table
Groups: php.db 
Request: Send a blank email to php-db+get-14744@lists.php.net to get a copy of this message
I'm working on an application that will allow resellers to log into the site and see their potential buyers. When they log in they see their potential buyers and by clicking a link they will get more detailed information about their contacts. They will also have a link to update their clients listings. As of now I have this set up like this... A person logs in and sees their contacts. If they click the update link they are takent to a page that lists their contact information. I've put the respected variables in the "value" attributes of the input tags. I want to make this process as easy as possible. I dont' want them to have to update every field if they just want to change a contact's phone number. Here's the problem...when they click the button to send the changes they still see their old information. I know that this is because I've set the value to their old variables. Does anyone know a way to get their old input in as the variable value and to still be able to see their new information on the next page. I also want this information to overwrite any existing record based on the potential contact's id. The sql section of the code I have looks like this: $sql = "INSERT INTO $table_name (id, contactid, fname, lname, title, cnl, address1, address2, city, state, postcode, country, phone, cell, fax, emailnl, smanager, percomplete, nfud, exrevenue, wl, cwl) VALUES (\"\", \"$contactid\", \"$fname\", \"$lname\", \"$title\", \"$cnl\", \"$address1\", \"$address2\", \"$city\", \"$state\", \"$postcode\", \"$country\", \"$phone\", \"$cell\", \"$fax\", \"$emailnl\", \"$smanager\", \"$percomplete\", \"$nfud\", \"$exrevenue\", \"$wl\", \"$cwl\") "; $result = @mysql_query($sql,$connection) or die("Couldn't execute query."); I know this doesn't overwrite each entry. I've also tried something like this: $sql = mysql_query("update my_contacts set fname=$fname, lname=$lname where id=$id"); Whenever I would try to run that query I would get an error back saying I couldn't execute that query. If anyone has any ideas I would be more than grateful. Thanks for your time. I'm new to the php/mysql world so if I didn't provide enough relevant code let me know. Thanks. Kevin

« previous php.db (#14744) next »