Hello,
I am really stuck and can't find the problem with the below script, I can not find out why it does not update the quantity i have tried and tried yet no look i will be highly grateful if any one can at all help me with this Thank you for looking
Code:
<?
include("db.php");
mysql_connect("$dbhost", "$dbuser", "$dbpasswd");
mysql_select_db("$dbname");
$table = "shopping";
include("shoppingcart.php");
$cart = new Cart;
include("header.php");
if($add)
{
if($ShoppingCart)
$session = $ShoppingCart;
$result = mysql_query( "SELECT * FROM inventory WHERE product='$add'");
$row = mysql_fetch_array($result);
$cart->add_item($table,$session,$row[product],1);
}
if($remove)
{
if($ShoppingCart)
{
$session = $ShoppingCart;
}
$result = mysql_query( "SELECT * FROM inventory WHERE product='$remove'");
$row = mysql_fetch_array($result);
$cart->delete_item($table,$session,$row[product]);
}
if($modify)
{
$contents = $cart->display_contents($table,$session);
for($i = 0; $i < sizeof($quantity); $i++)
{
$oldquan = $contents[quantity][$i];
$product = $contents[product][$i];
$newquan = $quantity[$product];
$cart->modify_quantity($table,$session,$product,$newquan);
}
}
// End update cart
$url = $PHP_SELF;
if(!$ShoppingCard)
$url .= "?session=$session";
echo "<FORM ACTION=$url method=post>\n";
?>
<BR><B>:: Shopping Cart</B><br><br>
<TABLE CELLSPACING=1 cellpadding=5 bgcolor=#cccccc>
<TR>
<TD WIDTH=40% bgcolor=#f8f8f8>Product</TD><TD WIDTH=10% bgcolor=#f8f8f8>Price</TD><TD WIDTH=20% bgcolor=#f8f8f8>Quantity</TD><TD WIDTH=20% bgcolor=#f8f8f8>Total</TD><TD bgcolor=#f8f8f8> </TD>
<?
if($ShoppingCart)
{
$session = $ShoppingCart;
}
$contents = $cart->display_contents($table,$session);
if($contents[product][0] != "")
{
$x = 0;
while($x != $cart->num_items($table,$session))
{
echo "<TR><TD bgcolor=#ffffff>".$contents[product][$x]."</TD><TD bgcolor=#ffffff>£".$contents[price][$x]."</TD>\n";
$product = $contents[product][$x];
echo "<TD bgcolor=#ffffff><INPUT TYPE=text size=3 name=quantity[$product] ";
echo "value=\"".$contents[quantity][$x]."\"></TD>";
echo "<TD bgcolor=#ffffff>£".$contents[total][$x]."</TD>\n";
echo "<TD bgcolor=#ffffff><A HREF=\"view_cart.php?remove=".urlencode($contents[product][$x]);
echo "".(!$ShoppingCart? "&session=$session":"")."\">Remove</A>";
$x ++;
}
echo "</TD><TR></TABLE>";
echo "<BR><B>Total Order Amount: £".$cart->cart_total($table,$session)."</B>";
echo "<BR><INPUT TYPE=submit name=modify value=\"Recalculate Order\">";
echo "<BR><BR>";
echo "Back to the <A HREF=\"store.php".(!$ShoppingCart? "?session=$session":"")."\">";
echo "Products</A> page";
}
else {
echo "You have 0 items in your shopping cart.";
}
echo"</form>";
include("footer.php");
?>