How to update multiple columns in mysql using php
Try like this :
$sql = "UPDATE product_list SET product_name='".$product_name."',product_category='".$product_category."',product_price='".$product_price."',product_description='".$product_description."',size_category='".$size_category."' WHERE product_id=".$product_id;
Reference : https://dev.mysql.com/doc/refman/5.0/en/update.html
You are mixing up query syntax between INSERT
and UPDATE
queries, the UPDATE
syntax is ;
UPDATE TABLE SET col1 = val1, col2=val2... WHERE col1 = val
You shall use the UPDATE
query as follows :
$sql = "UPDATE product_list SET product_name = '$product_name',
product_category = '$product_category' WHERE product_id = $product_id";
Update SQL query, see following method:
Update database_tablename SET column_name1 = column_value1 , column_name2 = column_value2
$sql = "UPDATE product_list SET product_name='".$product_name."',product_category='".$product_category."',product_price='".$product_price."',product_description='".$product_description."',size_category='".$size_category."'";
$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) ";