Home > Backend Development > PHP Problem > How to modify database data in php

How to modify database data in php

王林
Release: 2023-03-07 08:36:02
Original
5030 people have browsed it

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
Copy after login

(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);
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template