我的代码出了什么问题?它仅适用于列表中的一个项目。 [英] What's wrong with my code? It's working only for one item in list.

查看:60
本文介绍了我的代码出了什么问题?它仅适用于列表中的一个项目。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码有什么问题?

我试图更新购物车中每件商品的数量,但它并不适用于列表中的每个产品。



 <?php  
global $ con ;

include( includes / db.php);

$ ip = getIp();

if(isset($ _ POST [' update_cart'])){

$ qty = $ _POST [' 数量'];

$ update_qty = 更新购物车设置qty ='$ qty'其中ip_add ='$ ip';

$ run_qty = mysqli_query($ con,$ update_qty);

$ _SESSION [' qty'] = $ qty;

$ total = $ total * $ qty;

}
?>





我尝试了什么:



 < ;?php  
global $ con ;

include( includes / db.php);

$ ip = getIp();

if(isset($ _ POST [' update_cart'])){

$ qty = $ _POST [' 数量'];

$ update_qty = 更新购物车设置qty ='$ qty'其中ip_add ='$ ip';

$ run_qty = mysqli_query($ con,$ update_qty);

$ _SESSION [' qty'] = $ qty;

$ total = $ total * $ qty;

}
?>

解决方案

CON ;

include( includes / db.php);


ip = getIp();

if(isset(


_POST [' update_cart'])){


Whats wrong with My code?
I tried to update quantity for each product in shopping cart, but it's not working for every product in list separately.

<?php
  global $con;
  
  include("includes/db.php");
  
  $ip = getIp();

  if(isset($_POST['update_cart'])){
  
  $qty = $_POST['qty'];

  $update_qty = "update cart set qty='$qty' where ip_add='$ip'";
  
  $run_qty = mysqli_query($con, $update_qty);

  $_SESSION['qty']=$qty;

  $total = $total*$qty;
  
  }
?>



What I have tried:

<?php				
  global $con;
					
  include("includes/db.php");
					
  $ip = getIp();

  if(isset($_POST['update_cart'])){
					
    $qty = $_POST['qty'];

    $update_qty = "update cart set qty='$qty' where ip_add='$ip'";
					
    $run_qty = mysqli_query($con, $update_qty);

    $_SESSION['qty']=$qty;

    $total = $total*$qty;
					
  }
?>

解决方案

con; include("includes/db.php");


ip = getIp(); if(isset(


_POST['update_cart'])){


这篇关于我的代码出了什么问题?它仅适用于列表中的一个项目。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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