php method to implement mysql update: 1. Create a PHP sample file; 2. Connect to mysql; 3. Through "mysqli_query($con,"UPDATE Persons SET Age=36 WHERE FirstName=...)" The statement can be updated.
The operating environment of this article: Windows 7 system, PHP version 7.4, Dell G3 computer.
php How to implement mysql update?
PHP MySQL Update
UPDATE statement is used to modify the data in the database table.
Update the database The data
UPDATE statement is used to update records that already exist in the database table.
Syntax
1 2 3 |
|
Note: Please note the WHERE clause in the UPDATE syntax. WHERE clause Specifies which records need to be updated. If you want to omit the WHERE clause, all records will be updated!
In order for PHP to execute the above statement, we must use the mysqli_query() function. This function is used to A MySQL connection sends a query or command.
Example
In the previous chapters of this tutorial, we created a table named "Persons" as shown below:
1 2 3 |
|
The following example updates some data in the "Persons" table:
Example
1 2 3 4 5 6 7 8 9 10 11 |
|
After this update, the "Persons" table looks as follows:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to implement mysql update in php. For more information, please follow other related articles on the PHP Chinese website!