Home >Backend Development >PHP Problem >How to modify database data in php
How to modify database data in php: You can modify database data through the mysqli_query function combined with the update statement, such as [mysqli_query($con,"UPDATE Persons SET Age=36].
UPDATE statement is used to update existing records in the database table.
Syntax introduction:
UPDATE table_nameSET column1=value, column2=value2,...WHERE some_column=some_value
(Recommended video tutorial: java video tutorial )
Example:
First create a table named "Persons" as shown below:
The following Example updates some data in the "Persons" table:
<?php $con=mysqli_connect("localhost","username","password","database"); // 检测连接 if (mysqli_connect_errno()) { echo "连接失败: " . mysqli_connect_error(); } mysqli_query($con,"UPDATE Persons SET Age=36 WHERE FirstName='Peter' AND LastName='Griffin'"); mysqli_close($con); ?>
After this update, the "Persons" table looks like this:
Related recommendations:phptraining
The above is the detailed content of How to modify database data in php. For more information, please follow other related articles on the PHP Chinese website!