MySQL Update Data

Updating data in a MySQL table using PHP involves executing an SQL UPDATE statement through either procedural or object-oriented approaches.


Syntax:


UPDATE table_name SET column1 = value1, column2 = value2 WHERE condition;


  • table_name: The name of the table (e.g., users).
  • SET: Specifies the columns and their new values.
  • WHERE: Limits which rows are updated (use it carefully to avoid updating all rows).


The following example updates the name and age of the user with id=1.



Example (Procedural Method)

<!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

</head>

<body>


<h1>This is a Heading</h1>

<p>This is a paragraph.</p>


</body>

</html>

Example (Object-Oriented Method)

<!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

</head>

<body>


<h1>This is a Heading</h1>

<p>This is a paragraph.</p>


</body>

</html>

Example (PDO)

<!DOCTYPE html>

<html>

<head>

<title>Page Title</title>

</head>

<body>


<h1>This is a Heading</h1>

<p>This is a paragraph.</p>


</body>

</html>


Whereisstuff is simple learing platform for beginer to advance level to improve there skills in technologies.we will provide all material free of cost.you can write a code in runkit workspace and we provide some extrac features also, you agree to have read and accepted our terms of use, cookie and privacy policy.
© Copyright 2024 www.whereisstuff.com. All rights reserved. Developed by whereisstuff Tech.