Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement mysql updates in php

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how php implements mysql updates. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Php to achieve mysql update methods: 1, create a PHP sample file; 2, connect mysql;3, through the "mysqli_query ($con," UPDATE Persons SET Age=36 WHERE FirstName=...) statement to achieve update.

This article operating environment: Windows7 system, PHP7.4 version, Dell G3 computer.

PHP MySQL Update

The UPDATE statement is used to modify data in a database table.

Update the data in the database

The UPDATE statement is used to update records that already exist in the database table.

Grammar

UPDATE table_nameSET column1=value, column2=value2,...WHERE some_column=some_value

Note: please note the WHERE clause in the UPDATE syntax. The WHERE clause specifies which records need to be updated. If you want to omit the WHERE clause, all records will be updated!

In order for PHP to execute the above statement, we must use the mysqli_query () function. This function is used to send a query or command to a MySQL connection.

Example

In the previous chapters of this tutorial, we created a table called "Persons" as follows:

FirstNameLastNameAgePeterGriffin35GlennQuagmire33

The following example updates some data in the "Persons" table:

Example

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report