Code: Select all
<?php
$empty = TRUE;
if (isset($_SESSION['cart']))
{
foreach ($_SESSION['cart'] as $key => $value)
{
if (isset($value))
{
$empty = FALSE;
break;
}
}
}
if (!$empty)
{
include ('./mysql_connect.php');
$q = "SELECT product_name FROM products WHERE product_name IN (";
foreach ($_SESSION['cart'] as $product => $value)
{$query .= $product . ','; }
$q = substr ($query, 0, -1) . ') ORDER BY product_name ASC';
$result = mysql_query ($q) or die();
echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="20%"><b>Gift</b></td>
<td align="left" width="15%"><b>Price</b></td>
<td align="left" width="35%"><b>Quantity</b></td>
</tr
<form action="cart.php" method="post"> ';
$total = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo
"<tr>
<td align=\"left\">{$row['product_name']}</td>
<td align=\"right\">\£{$_SESSION['cart'][$row['product_name']]['price']}</td>
<td align=\"center\">\£{$_SESSION['cart'][$row['product_name']]['quantity']}</td>
</tr>\n";
}
mysql_free_result($result);
mysql_close();
echo '
</table>
<div align="center">
<input type="submit" name="submit" value="update cart" />
<input type="hideen" name-"submitted" value="TRUE" />
</form>';
}
else
{
echo ' Cart is empty';
}
?>