Jump to content

Switch Case problem


aarbrouk

Recommended Posts

Hello,

 

I have created a shopping cart by which a customer can successfully add products to it one by one. I have also enabled the customer to save the order. My problem is that I then need the customer to be able to amend the order (putting the product/s back into the shopping cart). My problem is as follows:

if (isset($_GET['action'])){
$action = $_GET['action'];
}
else {
$action ="";
}

switch ($action) {
case 'multi':
	if ($cart) {
	$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];

	} else {

	$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];	

	}
case 'add':
	if ($cart) {

		$cart .= ','.$_GET['ProductID'].':'.$_GET['SizeID'];
                    

	} else {
		$cart = $_GET['ProductID'].':'.$_GET['SizeID'];
	}
	break;

 

The 'action' that is passed through is "multi" and I pass through the productID and SizeID as expected. The correct information and right amount of products are displayed in the shopping cart. However i recieve an undefined index problem in the switch case "add". Why does it access the else statement in the add switch case when the action i passed through was "multi". In any case how do I stop it from accessing the "add" switch case if "multi" action is passed through??

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/156918-switch-case-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.