PHP MySQL Update

UPDATE 语句用于中修改数据库表中的数据。

ডাটাবেসের তথ্য আপডেট করা

UPDATE 语句用于在数据库表中修改数据。

গতিবিদ্যা

UPDATE table_name
SET column_name = new_value
WHERE column_name = some_value

Note:SQL is case-insensitive. UPDATE is equivalent to update.

To make PHP execute the above statement, we must use the mysql_query() function. This function is used to send queries and commands to the SQL connection.

Example

Earlier in this tutorial, we created a table named "Persons". It looks something like this:

FirstName LastName Age
Peter Griffin 35
Glenn Quagmire 33

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

<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("my_db", $con);

WHERE FirstName = 'Peter' AND LastName = 'Griffin'
mysql_close($con);
?>

After this update, the "Persons" table looks like this:

FirstName LastName Age
Peter Griffin 36
Glenn Quagmire 33