Home  >  Article  >  Backend Development  >  How to modify database data in php

How to modify database data in php

王林
王林Original
2020-11-04 11:14:305000browse

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].

How to modify database data in php

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:

How to modify database data in php

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=&#39;Peter&#39; AND LastName=&#39;Griffin&#39;");
mysqli_close($con);
?>

After this update, the "Persons" table looks like this:

How to modify database data in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn