njsuperfreak Posted November 9, 2007 Share Posted November 9, 2007 Example: http://www.bumsey.com/eventphoto/view_user_photo.php?PID=5&EVENTID=1 I want the PID from the url to be stored in a array or something each time a user adds a item to the shopping cart. So that PID follows the shopping cart item chosen. And I don't have to create several duplicate items in the Table. And I can just attach the photo to the shopping cart item. I could add the PID in the same table as the inventory but I would have to add the photo several times with each option. ( Example: 2 Commemorative Frames with 8X10 & Event Information $199.99) So I thought I could create an array or something. Any suggestions? Example code: <?php $cart = $_SESSION['cart']; $getuser = $_SESSION['getuser']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; $getuser .= ','.$_GET['PID']; } else { $cart = $_GET['id']; $getuser = $_GET['PID']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; case 'update': if ($cart) { $newcart = ''; foreach ($_POST as $key=>$value) { if (stristr($key,'qty')) { $id = str_replace('qty','',$key); $items = ($newcart != '') ? explode(',',$newcart) : explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($id != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } for ($i=1;$i<=$value;$i++) { if ($newcart != '') { $newcart .= ','.$id; } else { $newcart = $id; } } } } } $cart = $newcart; break; } $_SESSION['cart'] = $cart; $_SESSION['getuser'] = $getuser; ?> Quote Link to comment https://forums.phpfreaks.com/topic/76623-help-shopping-cart-blues/ Share on other sites More sharing options...
SilveR316 Posted November 9, 2007 Share Posted November 9, 2007 I think I went from trying to read your YELLOW code... Please change it to use the [ code ] tags so its actually readable and we might be able to help. Quote Link to comment https://forums.phpfreaks.com/topic/76623-help-shopping-cart-blues/#findComment-387972 Share on other sites More sharing options...
revraz Posted November 9, 2007 Share Posted November 9, 2007 I'm Blind Quote Link to comment https://forums.phpfreaks.com/topic/76623-help-shopping-cart-blues/#findComment-387975 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.