How MySQL updates database fields tutorial
Grammar
UPDATE table_name SET column_name = new_value WHERE column_name = some_value
Note: SQL is not sensitive to case. Update is equivalent to update.
In order for PHP to execute the above statement, we must use the mysql_query (function). This function is used to send queries and commands to a SQL connection.
Example
Earlier, we created a table named "Person" in this tutorial. It looks something like this:
FirstName LastName Age Peter Griffin Glenn Quagmire 33
The following example updates some of the data in the "person" table:
$con = mysql_connect ("localhost", "Peter", "abc123");
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
mysql_select_db ("my_db", $con);
mysql_query ("UPDATE person SET age = ' 36"
WHERE FirstName = ' Peter ' and LastName = ' Griffin ');
Mysql_close ($con);
?>
After this update, the "person" table is like this:
FirstName LastName Age
Peter Griffin 36
Glenn Quagmire 33
Note : More wonderful articles please pay attention to the triple programming Tutorial column.