How to implement mysql updates in php
This article is about how php implements mysql updates. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Php to achieve mysql update methods: 1, create a PHP sample file; 2, connect mysql;3, through the "mysqli_query ($con," UPDATE Persons SET Age=36 WHERE FirstName=...) statement to achieve update.
This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.
PHP MySQL Update
The UPDATE statement is used to modify data in a database table.
Update the data in the database
The UPDATE statement is used to update records that already exist in the database table.
Grammar
UPDATE table_nameSET column1=value, column2=value2,...WHERE some_column=some_value
Note: please note the WHERE clause in the UPDATE syntax. The 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 send a query or command to a MySQL connection.
Example
In the previous chapters of this tutorial, we created a table called "Persons" as follows:
FirstNameLastNameAgePeterGriffin35GlennQuagmire33
The following example updates some data in the "Persons" table:
Example