How does php modify database data based on 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 );
?>
Reply to discussion (solution)
ID is a number ''?
Can't you execute your update statement? It looks okay.
Update your table name set column name to be changed = value to be changed where id = id you specified
If I click review under each data entry based on the data in the preceding column, the data will be "reviewed" and written to the current data entry, the data currently written is written to the bottom data by default.
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]'";
$sql = "UPDATE wdksm SET rsshtime = '$_POST[test]' WHERE id = '$_POST[id]'";
This code cannot be written. how do I select an id and write data to this id without affecting the data of other IDs?
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'
';
}
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'
';
}
The eldest brother upstairs can't add the code according to your line.