libertyct Posted October 9, 2008 Share Posted October 9, 2008 I have simplified what i am trying to do and I setup an example below. basically im trying to figure out how to capture data posted from a Select with multiple options selected. any ideas? <form name="form" method="post" action="save.php" > <select name="categories" multiple > <option value="1" >1</option> <option value="2" selected >2</option> <option value="3" selected >3</option> </select> <input type="submit" value="submit" /> thnx! Quote Link to comment https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/ Share on other sites More sharing options...
DarkWater Posted October 9, 2008 Share Posted October 9, 2008 Change the select name attribute to "categories[]" so it becomes a multi-dimensional array in PHP that's filled with your values. Use print_r() on $_POST to see what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/#findComment-660531 Share on other sites More sharing options...
dropfaith Posted October 9, 2008 Share Posted October 9, 2008 this is tested and works just gotta edit your details in <form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <select name="test[]" multiple="multiple"> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> <option value="four">four</option> <option value="five">five</option> </select> <input type="submit" value="Send" /> </form> <?php $test=$_POST['test']; if ($test){ foreach ($test as $t){echo 'You selected ',$t,'<br />';} } ?> Quote Link to comment https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/#findComment-660532 Share on other sites More sharing options...
libertyct Posted October 9, 2008 Author Share Posted October 9, 2008 thnk u very much DarkWater & dropfaith works! Quote Link to comment https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/#findComment-660537 Share on other sites More sharing options...
DarkWater Posted October 9, 2008 Share Posted October 9, 2008 No problem. Please mark this topic as solved. Quote Link to comment https://forums.phpfreaks.com/topic/127643-post-a-multiple-select/#findComment-660538 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.