Zergman Posted November 14, 2008 Share Posted November 14, 2008 Whats the easiest way to pass a php array to another page? Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/ Share on other sites More sharing options...
rhodesa Posted November 14, 2008 Share Posted November 14, 2008 usually depends on the situation...but probably with a SESSION variable Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/#findComment-690352 Share on other sites More sharing options...
Zergman Posted November 14, 2008 Author Share Posted November 14, 2008 I got a select box as follows <select name="validmenu[]" class="inputbox" id="validmenu" size="3" multiple> <option value="*Valid*">*Valid*</option> <option value="Behaviour">Behaviour</option> <option value="Improper Abstract">Improper Abstract</option> <option value="Improper Route">Improper Route</option> <option value="Invalid STN">Invalid STN</option> <option value="Kudos">Kudos</option> <option value="Other">Other</option> <option value="Policy/Procedure">Policy/Procedure</option> <option value="Poor Ticket Creation">Poor Ticket Creation</option> <option value="Troubleshooting">Troubleshooting</option> </select> Thanks to the awesome help from the people on the boards, I have it comma separated. if (isset($_GET['validmenu'])) { $comma_separated = "'" . implode("','", $valid) . "'"; } else { $comma_separated = "'default'"; // or maybe some default value, like "'default'" } I tried the following example I found but it didn't work. <a href="sample2.php?<? for ($I=0, $I<count($array); $I++) echo "array[]={$array[$I]}&"; ?>"> How would I use a session variable to pass the array data to another page? Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/#findComment-690355 Share on other sites More sharing options...
wildteen88 Posted November 14, 2008 Share Posted November 14, 2008 First make sure you have session_start() as the first line of all pages that dealsw with sessions. Then use the following to assign the $comma_separated variable to your session. $_SESSION['comma_separated'] = $comma_separated; Now in the next page use $_SESSION['comma_separated'] to retrieve the comma separated list. Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/#findComment-690364 Share on other sites More sharing options...
The Little Guy Posted November 14, 2008 Share Posted November 14, 2008 Not sure if this is the right track... foreach($_POST['validmenu'] as $val){ echo '<p>'.$val.'</p>'; } Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/#findComment-690404 Share on other sites More sharing options...
Zergman Posted November 14, 2008 Author Share Posted November 14, 2008 Great stuff, working like a charm now! Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/132750-solved-passing-array-to-another-page/#findComment-690458 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.