Hi All,

I'm creating a shopping cart from following a tutorial online from TheTutSpace: http://www.youtube.c...A98B91CBF08F3A2

I have gotten up to the page where the cart should be displaying the products that have been added to the cart, and "Go To Cart" has been clicked. The page loads up correctly, however doesn't display any of the products that have been added to the cart. I know its storing them correctly as they are visible in the sidebar, they just aren't echoing out properly it seems.
I have also ran var_dump on $sql and $query, both returning the results that are expected of them.
The cart connects to the DB via a require_once which is located on my index.php so theres no issues there.


I have attached the cart.php page (which seems to be the only issue)
If you require more information, please do ask and i'll provide as much as i can!

The section i THINK is the issue is:

Code:
if(!empty($query)){
while($row = mysql_fetch_array($query)){
$subtotal = $_SESSION['cart'][$row['SKU']]['quantity']*$row['price'];
$total_price += $subtotal;
?>


<tr>
<td><?php echo $row['name']; ?></td>
<td><input type="text" name="quantity-<?php echo $row['SKU']; ?>" size="5" value="<?php echo $_SESSION['cart'][$row['SKU']]['quantity']; ?>" /></td>
<td><?php echo "£" . $row['price']; ?></td>
<td><?php echo "£" . $_SESSION['cart'][$row['SKU']]['quantity']*$row['price']; ?></td>
</tr>
<?php
} 
}else {
echo "<i>No Items founds to display!</i> ";
}
?>


I am new to PHP as you may have guessed, so please be kind

Code:
<?php 
		if(isset($_POST['submit'])){
		foreach($_POST as $key => $value) {
			$key = explode("-",$key);
			$key = end($key);
			$key = explode("submit",$key);
			$key = end($key);
			
			if($_POST['quantity-'.$key] == 0){
					unset($_SESSION['cart'][$key]);
					echo "Unset session";
				} else {
					$_SESSION['cart'][$key]['quantity'] = $value;
					echo "Updated session";
					}
				}
		} 
?>
<h1>View Cart</h1>
<a href="index.php?page=products" title="Go Back to products page">Go Back To Proucts Page</a>
<form method="OST" action="index.php?page=cart">
	<table>
		<tr>
			<th>Name</th>
			<th>Quantity</th>
			<th>Price Per Item</th>
			<th>Total Cost</th>
		</tr>
		<?php
		
			$sql = "SELECT * from products WHERE SKU IN(";
				foreach ($_SESSION['cart'] as $id => $value){
				$sql .= $id . ",";
				}
				$sql = substr($sql,0,-1.).") ORDER BY name ASC";
				$query = mysql_query($sql);
				$total_price = 0;
				if(!empty($query)){
				while($row = mysql_fetch_array($query)){
					$subtotal = $_SESSION['cart'][$row['SKU']]['quantity']*$row['price'];
					$total_price += $subtotal;
				?>
				
						<tr>
							<td><?php echo $row['name']; ?></td>
							<td><input type="text" name="quantity-<?php echo $row['SKU']; ?>" size="5" value="<?php echo $_SESSION['cart'][$row['SKU']]['quantity']; ?>" /></td>
							<td><?php echo "£" . $row['price']; ?></td>
							<td><?php echo "£" . $_SESSION['cart'][$row['SKU']]['quantity']*$row['price']; ?></td>
						</tr>
					<?php
					} 
					}else {
						echo "<i>No Items founds to display!</i> ";
					}
					?>
				<tr>
					<td></td>
					<td></td>
					<td>Total Price:</td>
					<td><?echo "£" . $total_price; ?></td>
				</tr>
	</table>
	<input type="submit" name="submit" vlaue="Update Cart" />
</fieldset>
</form>
<p>To remove an item, set quantity to 0</p>
				
							
							
				
	</table>