I want to add multiple items to a shopping cart, at the same time

Hi Guys…
I am setting a shopping cart and it works OK with BUY NOW buttons and adds the product to the cart one at a time.

However, I want to select a few items, via checkboxes, and pass them to the cart.php all at the same time. The shopping cart has facility to change the quantities and update the cart.

This is a chopped down version of the sending code:

		$main_content .= "<form action='cart/cart.php?action=add&id=$id' method='get' target='new'>";
		if($color==1){
		$main_content .= "<tr bgcolor='#ffcc99'>";
// ORDERS 1
		$main_content .= "<td valign='top'>$product <font color=#ff0000><b>$comments</b></font></td>";
		$main_content .= "<td valign='top'>$packquantity</td>\
";
		$main_content .= "<td valign='top'>&pound$trade</td>\
";

		$main_content .= "<td valign='top'><input type='checkbox' name='id' value='$id'>\
";

		$main_content .= "</tr>\
";


		$main_content .= "<input type='submit' value='Place Order'>";
		$main_content .= "&nbsp;&nbsp;&nbsp;&nbsp;<input type='reset' value='Clear'>";

		$main_content .= "</form></form></td></tr></table>\
";

The receiving code in my cart.php file is:

$cart = $_SESSION['cart'];
$action = $_GET['action'];

switch ($action) {
    case 'add':
        if ($cart) {
            $cart .= ','.$_GET['id'];
        } else {
            $cart = $_GET['id'];
        }
header("Location: cart.php");
        break;  

I think that the receiving code is wrong. It works OK for the BUY NOW button, one at a time, but it doesn’t work for multiple additions.

Can anybody help ???

Thanks,

John C

sooner or later i think you will need it so try to have array to store the values in cart
and one next thing multiple values can go in checkbox so start using id in the form and remember it is multidimensional array when you access it so $_GET[‘id’] wont work but $_GET[‘id’][0] will.

Thanks

Hi frank1…

Thank you for taking the time to reply to my query.
However, I did figure it out, after a long time, and it is now working fine.

Thank you,

John C