foreach($_SESSION['cart'] as $product_id => $quantity) {
$sql = "
SELECT Vendor, Product, Aisle, Bay, Price
FROM Products
WHERE idProducts = ?";
$s = $pdo->prepare($sql);
if($s === false):
print_r($pdo->errorInfo());
die;
endif;
$result = $s->execute(array($product_id));
if($result == =false):
print_r($s->errorInfo());
die;
endif;
//Only display the row if there is a product (though there should always be as we have already checked)
if(FALSE != ($row = $s->fetchObject())):
$line_cost = $row->Price * $quantity; //work out the line cost
$total += $line_cost; //add to the total cost
echo "<tr>"; //show this information in table cells
echo "<td align=\"center\">{$row->Product}</td>";
//along with a 'remove' link next to the quantity - which links to this page, but with an action of remove, and the id of the current product
echo "<td align=\"center\">$quantity <a href=\"$_SERVER[PHP_SELF]?action=remove&id=$product_id\">X</a></td>";
echo "<td align=\"center\">$line_cost</td>";
echo "</tr>";
endif;
endforeach;