aarbrouk Posted May 5, 2009 Share Posted May 5, 2009 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 More sharing options...
JonnoTheDev Posted May 5, 2009 Share Posted May 5, 2009 you are missing a break; at the end of the case Link to comment https://forums.phpfreaks.com/topic/156918-switch-case-problem/#findComment-826602 Share on other sites More sharing options...
aarbrouk Posted May 5, 2009 Author Share Posted May 5, 2009 thank you... Link to comment https://forums.phpfreaks.com/topic/156918-switch-case-problem/#findComment-826607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.