How does php modify data in the database according to the specified ID?

Source: Internet
Author: User
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'
';
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.