i'm trying to set up the shell for an online shopping cart and have everything working.... except the 'update' function. so, if someone has 1 item in their cart and wants 82, it all goes smoothly except the the database doesn't update with the new value.
i suspect it's the SQL statement, but i don't see any errors.... any ideas???
switch statement that gets called from the form
switch ($_GET['action'])
{
case "add_item":
{
AddItem($_GET['sessionId'], $_GET['id'], $_GET['qty']);
ShowCart();
break;
}
case "update_item":
{
UpdateItem($_GET['cart'], $_GET['qty']);
ShowCart();
break;
}
case "remove_item":
{
RemoveItem($_GET['cart']);
ShowCart();
break;
}
default:
{
ShowCart();
}
}
SQL statement
// Update items in cart
function UpdateItem($cartId, $qty) {
include ("config.php");
$query = "UPDATE cart SET qty = $qty WHERE cartId = $cartId";
$result = mysql_query($result);
}
the full code for this can be downloaded
here.