Forum Moderators: coopster
What I would like to do is have a simple form where the user can log on and update a list of neighborhoods.
The DB has a table called "neighborhoods".
I have the form set up to display the data from the table within a text area, so taht the user can make any changes, click "update" and it sends the new data back to the table.
Problem is, I've fooled around with insert, and it is creating new rows and thus duplicating the data. I've played with UPDATE but can't seem to get it to work. If anyone can give me a hint as to where I am going wrong, I would appreciate it. Here's the code:
$query = "update neighborhoods
SET
('".$_POST['neighborhoods']."')";
$result = mysql_query($query)
or die ("Unable to Add item. Please contact administrator");
The form is obviously posting one field, "neighborhoods". If I use "Insert Into..." in the query, it adds another row. Essentially all I want to happen is for the new $_POST to replace the existing data in the table.
ANy help would be greatly appreciated.
Pat
While updating, you should be able to loop and run the update query as many list of neighborhoods you have, each updating its own row.
while (....) {
$query = "update neighborhoods SET ('".$_POST['neighborhoods']."') WHERE id = '". $_POST['id'] ."'";
}
Habtom