- Messages
- 12
- Reaction score
- 0
- Points
- 16
Sir/ maam pa help need po ng tulong about sa code
Here's the code ung problema pag nag uupdate ako ng multiple products quantity ung subtotal nagiging zero paano poba ma separate un kc isang products lng po ang na uupdate nya salamat sa sasagot
<div id="products_box" style="margin-top: 15px";>
<!--Getting Products and Categories for displaying-->
<form action="" method="post" enctype="multipart/form-data" style="margin-left:10px;">
<center><table align="center" width="700" >
<tr align="center">
<th>Remove</th>
<th>Product (S)</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
<?php
$total = 0;
global $con;
$ip = getIp();
$sel_price = "select * from cart where ip_add='$ip'";
$run_price = mysqli_query($con, $sel_price);
while($p_price=mysqli_fetch_array($run_price)){
$pro_id = $p_price['p_id'];
$pro_price = "select * from products where product_id='$pro_id'";
$run_pro_price = mysqli_query($con, $pro_price);
while($pp_price = mysqli_fetch_array($run_pro_price)){
$product_price = array($pp_price['product_price']);
$product_title = $pp_price['product_title'];
$product_image = $pp_price['product_image'];
$single_price = $pp_price['product_price'];
$values = array_sum($product_price);
$total += $values;
?>
<tr>
<td> <input type="checkbox" name="remove[]" value="<?php echo $pro_id;?>"/></td>
<td style="font-size:12px;"><?php echo $product_title; ?><br>
<img src=" admin_area/product_images/<?php echo $product_image;?>" width="40" height="40" /></td>
<td><input type="text" size="4" name="qty" value="<?php echo $_SESSION['qty'];?>"/></td>
<?php
if(isset($_POST['update_cart'])){
$qty = $_POST['qty'];
$update_qty = "update cart set qty='$qty'";
$run_qty = mysqli_query($con, $update_qty);
$_SESSION['qty']=$qty;
$total = $total*$qty;
}
?>
<td> <?php echo "₱" ." ". $single_price ;?></td>
</tr>
<?php } } ?>
<tr align="right">
<td colspan="5"><b>Sub Total:</b></td>
<td><?php echo "₱" .$total;?></td>
</tr>
Here's the code ung problema pag nag uupdate ako ng multiple products quantity ung subtotal nagiging zero paano poba ma separate un kc isang products lng po ang na uupdate nya salamat sa sasagot
<div id="products_box" style="margin-top: 15px";>
<!--Getting Products and Categories for displaying-->
<form action="" method="post" enctype="multipart/form-data" style="margin-left:10px;">
<center><table align="center" width="700" >
<tr align="center">
<th>Remove</th>
<th>Product (S)</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
<?php
$total = 0;
global $con;
$ip = getIp();
$sel_price = "select * from cart where ip_add='$ip'";
$run_price = mysqli_query($con, $sel_price);
while($p_price=mysqli_fetch_array($run_price)){
$pro_id = $p_price['p_id'];
$pro_price = "select * from products where product_id='$pro_id'";
$run_pro_price = mysqli_query($con, $pro_price);
while($pp_price = mysqli_fetch_array($run_pro_price)){
$product_price = array($pp_price['product_price']);
$product_title = $pp_price['product_title'];
$product_image = $pp_price['product_image'];
$single_price = $pp_price['product_price'];
$values = array_sum($product_price);
$total += $values;
?>
<tr>
<td> <input type="checkbox" name="remove[]" value="<?php echo $pro_id;?>"/></td>
<td style="font-size:12px;"><?php echo $product_title; ?><br>
<img src=" admin_area/product_images/<?php echo $product_image;?>" width="40" height="40" /></td>
<td><input type="text" size="4" name="qty" value="<?php echo $_SESSION['qty'];?>"/></td>
<?php
if(isset($_POST['update_cart'])){
$qty = $_POST['qty'];
$update_qty = "update cart set qty='$qty'";
$run_qty = mysqli_query($con, $update_qty);
$_SESSION['qty']=$qty;
$total = $total*$qty;
}
?>
<td> <?php echo "₱" ." ". $single_price ;?></td>
</tr>
<?php } } ?>
<tr align="right">
<td colspan="5"><b>Sub Total:</b></td>
<td><?php echo "₱" .$total;?></td>
</tr>