cart quantity help

Hi, all

im trying to change this code, so that the quantity is changed by typing in the number and an update button instead of pressing the plus button each time to update the quantity

any ideas on how you do this?

thanks

[php]

<? session_start(); include 'connect.php'; if (isset($_GET['add'])){ $_SESSION['cart_'.(int)$_GET['add']]+='1'; header ('location: /cart.php'); } if (isset($_GET['remove'])){ $_SESSION['cart_'.(int)$_GET['remove']]--; header ('location: /cart.php'); } if (isset($_GET['delete'])){ $_SESSION['cart_'.(int)$_GET['delete']] ='0'; header ('location: /cart.php'); } function paypal_items(){ $num = 0; foreach($_SESSION as $name => $value){ if ($value>0){ if (substr($name, 0, 5) =='cart_'){ $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT * FROM list WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)){ $num++; $price = $get_row["Price"]; echo ''; echo ''; echo ''; echo ''; } } } } } function cart(){ foreach($_SESSION as $name => $value){ if ($value>0){ if (substr($name, 0, 5) =='cart_'){ $id = substr($name, 5, (strlen($name)-5)); $get = mysql_query('SELECT * FROM sostyrelist WHERE id='.mysql_real_escape_string((int)$id)); while ($get_row = mysql_fetch_assoc($get)){ $price = $get_row["Price"]; $desc = $get_row["Description"]; $sub = number_format($price, 2)*$value; ?>
                <div id="cartrow">
<? echo $get_row['Description']?>
<? echo $value ?>
£<? echo number_format($price, 2) ?>
£<? echo number_format($sub, 2) ?>

<? } } $total += $sub; } } if ($total==0){ echo '

Your cart is empty

'; } else{ //if ($value>3){$total = $total-10; //$discount = '
Multibuy saving - You have saved £10.00
';} $total = number_format($total, 2); echo '

Your total is : £'.$total.'

'; ?> <? echo paypal_items()?>



<? } }

?>
[/php]

What system are you using for the cart?

You could change the hidden quantity to a text field and remove the unnecessary buttons.

Sponsor our Newsletter | Privacy Policy | Terms of Service