Answer the question
In order to leave comments, you need to log in
After editing a record on the web page, all records in the database are updated?
I select an entry on the web page, I want to update only it, and all entries in the database are updated and replaced with this particular entry. Why is that and how to fix it?
require 'connect.php';
$id=$_REQUEST['id'];
$text=trim($_REQUEST['text']);
$age=trim($_REQUEST['age']);
$mail=trim($_REQUEST['mail']);
$gender=trim($_REQUEST['gender']);
$smoking=trim($_REQUEST['smoking']);
$update_sql = "UPDATE tabl1 SET text='$text', age='$age', mail='$mail', gender='$gender' , smoking='$smoking' WHERE id='$id'";
mysql_query($update_sql) or die("Ошибка вставки" . mysql_error());
echo '<p>Запись успешно обновлена!</p>';
Answer the question
In order to leave comments, you need to log in
I'm embarrassed to ask, do you have different records in your table that have different values for the id field?
before mysql_query()
paste die($update_sql);
and check the code.
hopefully somewhere in there..... you are filtering $_REQUEST otherwise you will be in for a big surprise... someday, from someone..
ps use mysqli/pdo
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question