<?php @session_start();
include ("../conf/conn.php");
//select
@$username = $_SESSION['username'];
@$id = $_SESSION['id'];
$query = "select * from cart where username='$username'";
$result = mysqli_query($conn,$query);
if (mysqli_num_rows($result) > 0) {
	
$query1 = "select * from cart where username='$username'";
$result1 = mysqli_query($conn,$query1);
while($row1 = mysqli_fetch_assoc($result1)) {
	global $item_amount,$cartsubtotal;
	@$item_amount= $item_amount + $row1["amount"];
	@$cartsubtotal=$cartsubtotal + ($row1["amount"]*$row1["price"]);
}
	
echo "<div class='cart-header' style='font-size: 13px;'>Item (s): ".$item_amount;
echo "&nbsp;&nbsp;&nbsp;&nbsp;Total: HK$".$cartsubtotal."</div>";

	while($row = mysqli_fetch_assoc($result)) {

//show
        
        
        echo "<div>";
            echo "<img src='".$row["image"]."' class='cart-item-img'>";
            echo "<div class='cart-item-info'>";
                echo "<div class='cart-item-name'>";
                   echo $row['product_name'];
                echo "</div>";
                echo "<div class='cart-item-price'>";
                    echo $row["amount"]." X HK$".$row["price"]."<br>";
					echo "<a style='font-size:15px' href='includes/add_cart.php?check=delete&name=".$row["product_name"]."&from=cart'>remove</a>";
                echo "</div>";
            echo "</div>";
        echo "</div>";
	}
	
echo "<div class='checkout-div'>";
          echo "<a href='includes/checkout.html' class='btn-primary'>";
               echo "Check&nbsp;Out";
          echo "</a>";
        echo "</div>";
}			
else{
        echo "<div class='cart-item-info'>";
            echo 'none.';
        echo "</div>";
}

    
?>