How does php modify database data according to the specified ID? php & nbsp; how does php modify database data according to the specified ID & nbsp; & lt ;? Php & nbsp; & nbsp; & nbsp php: how to modify database data according to the specified ID
How does php modify data in the database according to the specified ID?
$ Query = mysql_query ('select * FROM wdksm ');
While ($ row = mysql_fetch_assoc ($ query ))
{{
$ Id = $ row ['id'];
Echo 'date: '. $ row ["time"]. '';
Echo 'Department: '. $ row ["bumen"]. '';
Echo 'name: '. $ row ["name"]. '';
Echo 'Title: '. $ row ["zhiwu"].'
';
Echo 'time not punched in: '. $ row ["wdktime"].'
';
Echo 'The reason for not logging in: '. $ row ["wdkyy"].'
';
Echo 'Department owner review: '. $ row ["bmshtime"]. '';
Echo 'approval from the personnel administration department/General Manager: '. $ row ["rsshtime"].'
';
}
Echo '';
Echo'
';
}
$ SQL = 'update wdksm SET
Rsshtime = \ ''. $ _ POST ['test']. '\'
WHERE id = \ ''. $ id .'\'';
Mysql_query ($ SQL );
?>
------ Solution ----------------------
Your form is generated in this way.
echo '';
There is no id value in it
Therefore, the submitted data does not contain a unique identification id.
The id in your SQL command is the last id when the list is generated. of course, this is wrong.
In addition, the writing of your SQL commands is weird.
This is better written.
$sql = "UPDATE wdksm SET rsshtime = '$_POST[test]' WHERE id = '$_POST[id]'";
------ Solution ----------------------
While ($ row = mysql_fetch_assoc ($ query ))
{
$ Id = $ row ['id'];
Echo 'date: '. $ row ["time"]. '';
Echo 'Department: '. $ row ["bumen"]. '';
Echo 'name: '. $ row ["name"]. '';
Echo 'Title: '. $ row ["zhiwu"].'
';
Echo 'time not punched in: '. $ row ["wdktime"].'
';
Echo 'The reason for not logging in: '. $ row ["wdkyy"].'
';
Echo 'Department owner review: '. $ row ["bmshtime"]. '';
Echo 'approval from the personnel administration department/General Manager: '. $ row ["rsshtime"].'
';
Echo '';
Echo'
';
}