Php 将动态文本框值保存到MySQL

Php 将动态文本框值保存到MySQL,php,phpmyadmin,Php,Phpmyadmin,我想从购物车文本框保存动态文本框中的数据。我的代码如下。我没办法存钱 (32B到40B是文本框名称和表列名) 您的foreach似乎有点不对劲。没有看到完整的表单,我不确定$\u POST['remove/update']是否正确,但如果正确,应该可以 global $con; if(isset($_POST['update_cart'])){ foreach($_POST['remove'] as $update){ $size_1 = $update['32B'];

我想从购物车文本框保存动态文本框中的数据。我的代码如下。我没办法存钱

(32B到40B是文本框名称和表列名)


您的
foreach
似乎有点不对劲。没有看到完整的表单,我不确定
$\u POST['remove/update']
是否正确,但如果正确,应该可以

global $con;    
if(isset($_POST['update_cart'])){

  foreach($_POST['remove'] as $update){
    $size_1 = $update['32B'];
    $size_2 = $update['34B'];
    $size_3 = $update['34C'];
    $size_4 = $update['36B'];
    $size_5 = $update['36C'];
    $size_6 = $update['38B'];
    $size_7 = $update['38C'];
    $size_8 = $update['40B'];

    $update_qty = "update cart set 32B='$size_1', 34B='$size_2', 34C='$size_3', 36B='$size_4', 36C='$size_5', 38B='$size_6', 38C='$size_7', 40B='$size_8'";
    mysqli_query($con, $update_qty);


    echo $update_qty;

  }
}

你有什么错误吗?请使用准备好的报表。没有,我没有收到任何错误,但我担心的是,例如,如果我在表中的每行输入40个32B大小的数量,它将更新相同的值(40个数量)…你能共享生成
$\u POST
值的表单吗?我已经更新了代码。请删除您的答案并添加任何与您的问题相关的内容。我同意RST,+1。不错的答案(顺便说一句:)
global $con;    
if(isset($_POST['update_cart'])){

  foreach($_POST['remove'] as $update){
    $size_1 = $update['32B'];
    $size_2 = $update['34B'];
    $size_3 = $update['34C'];
    $size_4 = $update['36B'];
    $size_5 = $update['36C'];
    $size_6 = $update['38B'];
    $size_7 = $update['38C'];
    $size_8 = $update['40B'];

    $update_qty = "update cart set 32B='$size_1', 34B='$size_2', 34C='$size_3', 36B='$size_4', 36C='$size_5', 38B='$size_6', 38C='$size_7', 40B='$size_8'";
    mysqli_query($con, $update_qty);


    echo $update_qty;

  }
}