The method for PHP to modify mysql data is to use the update statement combined with the mysqli_query function to achieve the modification, such as [mysqli_query($con,"UPDATE Persons SET Age=36 WHERE words].
The UPDATE statement is used to update existing records in the database table.
(Related tutorial recommendations: mysql tutorial)
Syntax:
UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value
In order for PHP to execute the above statement, we must use the mysqli_query() function. This function is used to send queries or commands to the MySQL connection.
Example:
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); ?>
Updated Persons table
Related recommendations: php training
The above is the detailed content of What is the method for modifying mysql data in php. For more information, please follow other related articles on the PHP Chinese website!