Solarpitch Posted December 19, 2006 Share Posted December 19, 2006 Hey guys,Bascially what I am trying to achieve is..I want to set up a session variable that keeps track of values that are added to it across different pages in a site.eg:session variable = 'id_values'Page1 Page2option1 (id=1) option1 (id=1)option2 (id=2) option2 (id=1)option3 (id=3) option3 (id=1)option4 (id=4) option4 (id=1)So if user select option1 and option4 on page 1, it stores the values 1 & 4 in 'id_values' . . thenif user select option1 and option2 on page 2, it stores the values 1 & 2 in 'id_values' along with page 1 values. so'id_values' = {1, 4, 1, 2} . . hahaha I hope that makes sense!Anyone here handy at using session variables? Link to comment https://forums.phpfreaks.com/topic/31257-session-variables-storing-accumulated-values/ Share on other sites More sharing options...
thepip3r Posted December 19, 2006 Share Posted December 19, 2006 yes... this could be very simply done using session variables... just use a different dimension of your session array. in your example, on page 1, if it's clicked:[code]if ($_POST['submit']) { if (is_array($_POST['options']) { foreach ($_POST['options'] as $array_element) { $_SESSION['checked_options'][] = $array_element); } }}[/code]With something like the above, you just have a 2 dimensional array where all of your clicked options are listed in the $_SESSION['checked_options'] array. Link to comment https://forums.phpfreaks.com/topic/31257-session-variables-storing-accumulated-values/#findComment-144617 Share on other sites More sharing options...
Solarpitch Posted December 19, 2006 Author Share Posted December 19, 2006 Sweet . .Thats how its done so. I hate arrays tho, anytime I hear that word . . I RUN! :DCheers man Link to comment https://forums.phpfreaks.com/topic/31257-session-variables-storing-accumulated-values/#findComment-144620 Share on other sites More sharing options...
thepip3r Posted December 19, 2006 Share Posted December 19, 2006 Let me give you a little piece of advice... PHP is a GOD among languages when it comes to array support. Enjoy it while you can because if you try to go to another language (say, VBscript, KiX, etc), it's a nightmare. =Pand if you have problems, you always have us. =P Link to comment https://forums.phpfreaks.com/topic/31257-session-variables-storing-accumulated-values/#findComment-144626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.