php 数组到字符串转换电子商务网站

k7fdbhmy  于 2023-01-08  发布在  PHP
关注(0)|答案(1)|浏览(171)
    • D中的数组到字符串的转换:\obada\xampp\htdocs\eccomerce\cart. php51行**

第65行D:\obada\xampp\htdocs\eccomerce\cart. php中的数组到字符串转换

<td class="quantity"><div class="input-group btn-block" style="max-width: 200px;">
  *this is line 51*  <input type="text" name="obd[]" size="5" value="" class="form-control"/>
<?php 
        global $connect;
        $ip=getIp();
        if(isset($_POST['update_cart'])){
        foreach($_POST['obd'] as $id_upd){
        $rev = $_POST['obd'];
*this is line 65* $update_rev = "update cart set raw='$rev' where p_id = '$id_upd' AND ip_add = '$ip'";
        $run_u_rev = mysqli_query($connect, $update_rev);
        $_SESSION['obd']=$rev;
        
    } }?>

我尝试使用foreach并使用更新购物车set raw ='$rev '

vwkv1x7d

vwkv1x7d1#

您正尝试更新key和value中的每个值,因此需要执行以下操作:

<?php

    global $connect;
    $ip=getIp();

    if (isset($_POST['update_cart'])) {
      foreach($_POST['obd'] as $key => $rev) {
       $update_rev = "update cart set raw='$rev' where p_id = '$key' AND ip_add = '$ip'";
       $run_u_rev = mysqli_query($connect, $update_rev);
       $_SESSION['obd'][] = $rev;
    
      } 
    }

相关问题