如何使用php更新mysql中的多个列 [英] How to update multiple columns in mysql using php

查看:39
本文介绍了如何使用php更新mysql中的多个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里我正在尝试使用 php 更新更新 mysql 表中的多个列值.

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')";
}"

我有 5 个列值要在表中更新,我正在使用变量来保存数据并使用该变量想要更新表中的值我该怎么做?

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?

推荐答案

 $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) ";

这篇关于如何使用php更新mysql中的多个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆