0
$cartOutput = "";
$cartTotal = "";
$ctr= 0;
$collector = array();
$product_id_array = '';
if (!isset($_SESSION["cart_array"]) || count($_SESSION["cart_array"]) < 1) {
    $cartOutput = "<h2 align='center'>Your shopping cart is empty</h2>";
} else {

    $i = 0; 
    foreach ($_SESSION["cart_array"] as $each_item) { 
        $item_id = $each_item['item_id'];
        $sql = mysql_query("SELECT * FROM products WHERE id='$item_id' LIMIT 1");
        while ($row = mysql_fetch_array($sql)) {
            $product_name = $row["product_name"];
            $price = $row["price"];
            $details = $row["details"];





        }

        $pricetotal = $price * $each_item['quantity'];
        $cartTotal = $pricetotal + $cartTotal;


        $product_id_array .= "$item_id-".$each_item['quantity'].","; 
        $cartOutput .= "<tr>";
        $cartOutput .= '<td><a href="product.php?id=' . $item_id . '">' . $product_name . '</a><br /><img src="inventory_images/' . $item_id . '.jpg" alt="' . $product_name. '" width="40" height="52" border="1" /></td>';
        $cartOutput .= '<td>' . $details . '</td>';
        $cartOutput .= '<td>₱' . $price . '</td>';
        $cartOutput .= '<td><form action="cart.php" method="post">
        <input name="quantity" type="text" value="' . $each_item['quantity'] . '" size="1" maxlength="2" />
        <input name="adjustBtn' . $item_id . '" type="submit" value="change" />
        <input name="item_to_adjust" type="hidden" value="' . $item_id . '" />
        </form></td>';
        $cartOutput .= '<td>' . $pricetotal . '</td>';
        $cartOutput .= '<td><form action="cart.php" method="post"><input name="deleteBtn' . $item_id . '" type="submit" value="X" /><input name="index_to_remove" type="hidden" value="' . $i . '" /></form></td>';
        $cartOutput .= '</tr>';




        //$collector [$ctr][] =  $item_id;
        //$collector [$ctr][] =  $product_name;
        //$collector [$ctr][] =  $price;
        //$collector [$ctr][] =  $pricetotal;
        //$collector [$ctr][] =  $cartTotal;





     $ctr++;

     //$itemid = $item_id;
     // $productname = $product_name;
     // $prices = $price        ;
     // $pricetotals = $pricetotal;
     // $total = $cartTotal;

            $i++; 

     //  foreach ($collector as $key => $values) {
//echo $values; }
// if ($_POST['checkout']) {

    //  mysql_query("INSERT INTO transaction (trans_id, transaction_num, item_id, product_name, price, pricetotal, total) VALUES ('','$transnum','$itemid','$productname','$prices','$pricetotals','$total')");
//}

         }



}

echo var_export($collector);
3
Contributors
2
Replies
15
Views
4 Years
Discussion Span
Last Post by diafol
0

I see only a block of code, without any description for what you want
Can you provide us with more details ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.