Hello. The database has a table prom_item
id - AUTO_INCREMENT
trip - INT
name - varchar unique
date - varchar
I try to make sure that if there is already an entry in the database that matches the value of the name cell, and this field is edited, then it is necessary that the row is updated in the database, and if not, a new entry is created.
On server:
foreach ($_POST['prpunkt'] as $k => $f) { $namepp = $_POST['prpunkt'][$k]; mysql_query("INSERT INTO `prom_item` (`trip`, `name`) values('$nw_id', '$namepp') ON DUPLICATE KEY UPDATE name='$namepp')"); } As a result, it turns out that if I change the record, (the value of $ _POST ['prpunkt'] [$ k]), the string in the database is not updated, but a new one is written, and the old one remains.
what am i missing
tripis the id of the article to which I attach additional fields. what does it have to do with it? - iKeyprom_itemtable - additional fields may have an indefinite number of each article. that is, the trip values — the id of the article to which this field is attached cannot be unique already. - iKeyINSERT ON DUPLICATE KEY UPDATEdoes not suit you, since you are changing the field with a unique key, and not the fields accompanying it. - Visman