dragon_sa Posted December 20, 2010 Share Posted December 20, 2010 I have the following session variables for each item in a cart, which gets updated each time an item is added from the catalog // Register the session variables $_SESSION['ses_basket_items']=$ses_basket_items; $_SESSION['ses_basket_name']=$ses_basket_name; $_SESSION['ses_basket_amount']=$ses_basket_amount; $_SESSION['ses_basket_price']=$ses_basket_price; $_SESSION['ses_basket_stockcode']=$ses_basket_stockcode; $_SESSION['ses_basket_image']=$ses_basket_image; $_SESSION['ses_basket_size']=$ses_basket_size; $_SESSION['ses_basket_sizechoice']=$ses_basket_sizechoice; $_SESSION['ses_basket_id']=$ses_basket_id; I have a current cart page which loops through the sessions and displays them in a form. I have a check box for each item with the name="remove[]" and the value is the itemID which is the $ses_basket_id of item in the session. I have a select box with name="size[]" and the value is the users selected size for each item in the session which is $ses_basket_size Finnally I have a quantity text box with name="quantity[]" and the value is the users quantity value selected which is $ses_basket_amount. After all the looping through the products displaying each item in a row I have an update cart submit button name="change" outside the loop. What I want to know is how do I setup to perform each of these actions for each item in the session, how do I create the foreach loops for each array to delete or modify the correct items in the session if they are modified. I have the code to perform each task but dont know how to loop it through for each item in the session affecting only the correct session items. so if I have 3 items in the session for example, and I want to change the size of item 1, remove item 2 and change item 3 for quantity 1 to quantity 3 with only the 1 form and change button for all items and actions? Hope that makes sense any help with this would be appreciated. Link to comment https://forums.phpfreaks.com/topic/222204-modify-or-delete-multiple-items-from-a-session/ Share on other sites More sharing options...
dragon_sa Posted December 21, 2010 Author Share Posted December 21, 2010 Should I be echoing the itemID in the square brackets to use as a key for each action? eg name=remove"[itemID]" name="size[itemID]' name="quantity[itemID]" then what would be the best way to perform the actions? Link to comment https://forums.phpfreaks.com/topic/222204-modify-or-delete-multiple-items-from-a-session/#findComment-1149871 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.