search
HomeBackend DevelopmentPHP ProblemWhat is the method for modifying mysql data in php

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

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

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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!