php-mysqlHow to write an update query in MySQL using PHP?
An update query in MySQL using PHP can be written using the mysqli_query()
function. The syntax for this function is as follows:
mysqli_query($connection, "UPDATE table_name SET column1=value1, column2=value2 WHERE some_column=some_value");
This query will update the values of column1
and column2
in the table table_name
where some_column
is equal to some_value
.
The parts of the code are as follows:
$connection
: This is the connection to the MySQL database.UPDATE table_name
: This is the name of the table to be updated.SET column1=value1, column2=value2
: This is the list of columns and values to be updated.WHERE some_column=some_value
: This is the condition for which rows should be updated.
Helpful links
More of Php Mysql
- How to use a variable in a MySQL query using PHP?
- How to update to null value in MySQL using PHP?
- How to get the version of MySQL using PHP?
- How to use utf8mb4_unicode_ci in MySQL with PHP?
- How to get the error message for a MySQL query using PHP?
- How to change database in MySQL with PHP?
- How to use a MySQL union in PHP?
- How to set a timeout for MySQL query in PHP?
- How to use MySQL transactions in PHP?
- How to order by a column in ascending order in MySQL using PHP?
See more codes...