Here i am trying to update update multiple column values in mysql table using php.
$product_id = mysqli_real_escape_string($link, $_POST['product_id']);
$product_name = mysqli_real_escape_string($link, $_POST['product_name']);
$product_category = mysqli_real_escape_string($link, $_POST['product_category']);
$sql = "UPDATE product_list (product_name, product_category, product_price,product_description,product_size_category) VALUES ('$product_name', '$product_category', '$product_price', '$product_description', '$size_category')";
}"
i have 5 column values to be updated in table, i am using variable to save data and using that variable want to update the values in table how can i do that?
MySQL UPDATE command can be used to update multiple columns by specifying a comma separated list of column_name = new_value. Where column_name is the name of the column to be updated and new_value is the new value with which the column will be updated.
We can update multiple columns by specifying multiple columns after the SET command in the UPDATE statement. The UPDATE statement is always followed by the SET command, it specifies the column where the update is required.
To update multiple columns use the SET clause to specify additional columns. Just like with the single columns you specify a column and its new value, then another set of column and values. In this case each column is separated with a column.
To set all values in a single column MySQL query, you can use UPDATE command. The syntax is as follows. update yourTableName set yourColumnName =yourValue; To understand the above syntax, let us create a table.
$sql = "UPDATE `product_list` SET
`product_name` = '$product_name',
`product_category` = '$product_category',
`product_price` = '$product_price',
`product_description` = '$product_description',
`product_size_category` = '$size_category'
where clause..... (if required) ";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With