What is the method for modifying mysql data in php

王林
Release: 2023-03-07 14:16:02
Original
1987 people have browsed it

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

What is the method for modifying mysql data in php

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

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:

What is the method for modifying mysql data in php

<?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

Updated Persons table

What is the method for modifying mysql data in php

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!