AnotherQuestion Posted October 4, 2009 Share Posted October 4, 2009 What I would like to happen is: User selects a description from a SelectMenu. On Select they post the form using GET method. When the page is posted back the user then gets alist of the items they have selected ( A mini shopping cart). so far I have $Bookings=array($Bookings,$_GET['BookingID']); $_SESSION['ServicesReqID'] = $Bookings; and the ECHO looks like foreach($_SESSION['ServicesReqID'] as $key=>$value) { echo $key.$value; } All that happens is the last array changes value instead of adding on Link to comment https://forums.phpfreaks.com/topic/176476-session-array/ Share on other sites More sharing options...
.josh Posted October 4, 2009 Share Posted October 4, 2009 Think maybe you mean to do this: $_SESSION['ServicesReqID'][] = $Bookings; and foreach($_SESSION['ServicesReqID'] as $k) { foreach ($k as $key => $value) { echo $key.$value; } } Link to comment https://forums.phpfreaks.com/topic/176476-session-array/#findComment-930244 Share on other sites More sharing options...
AnotherQuestion Posted October 4, 2009 Author Share Posted October 4, 2009 tried that & got: Warning: Invalid argument supplied for foreach() Link to comment https://forums.phpfreaks.com/topic/176476-session-array/#findComment-930257 Share on other sites More sharing options...
mrMarcus Posted October 4, 2009 Share Posted October 4, 2009 to my knowledge (experience), $_SESSION['ServicesReqID'][] is not permitted. you must first create the array() with a common variable (e.g., $ServicesReqID[]), and then you can dump the array into a session var (e.g., $$_SESSION['ServicesReqID'] = $ServicesReqID;). aside from that, i need more information regarding your form and content of various variable names .. i got out of the guessing game a while back. what is $bookings in your array? $Bookings=array($Bookings,$_GET['BookingID']); Link to comment https://forums.phpfreaks.com/topic/176476-session-array/#findComment-930295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.