$ids = array(); foreach ($_SESSION['cart'] as $id => $value) { array_push($ids, $id); } echo "<h4>Order Summary</h4>"; //start table echo "<table class='table table-hover table-responsive table-bordered' style='margin:0 0 3em 0;'>"; // our table heading echo "<tr>"; echo "<th class='textAlignLeft'>Product Name</th>"; echo "<th>Price (USD)</th>"; echo "<th style='width:15em;'>Quantity</th>"; echo "<th>Sub Total</th>"; echo "</tr>"; // read products based on product ids in session cart $stmt = $product->readByIds($ids); // initialize total price $total_price = 0; // loop throught the products in the cart while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { extract($row); $quantity = $_SESSION['cart'][$id]['quantity']; $sub_total = $price * $quantity; // display products ordered echo "<tr>"; echo "<td>"; echo "<div class='product-id' style='display:none;'>{$id}</div>"; echo "<div class='product-name'>{$name}</div>"; echo "</td>"; echo "<td>$" . number_format($price, 2, '.', ',') . "</td>"; echo "<td>";