darkhappy Posted April 9, 2008 Share Posted April 9, 2008 You need to make the name of the field an array: <form method="post" action="foo.php"> <select name="bar[]" multiple> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> </select> <input type="submit" name="submit" value="Submit" /> </form> Then you will get multiple values returned. Ken could someone show me what the code would look like to put the data from this array into var's once it's posted? thanks, bb Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/ Share on other sites More sharing options...
trq Posted April 9, 2008 Share Posted April 9, 2008 <?php explode($_POST['bar']); ?> Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/#findComment-512628 Share on other sites More sharing options...
Northern Flame Posted April 9, 2008 Share Posted April 9, 2008 <?php foreach($_POST['bar'] as $val){ echo "$val<br />\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/#findComment-512629 Share on other sites More sharing options...
darkhappy Posted April 9, 2008 Author Share Posted April 9, 2008 <?php explode($_POST['bar']); ?> cool thanks - how would i know what size to create the sql table that i want to put the selected values into since i don't know how many the user is going to select? Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/#findComment-512635 Share on other sites More sharing options...
trq Posted April 9, 2008 Share Posted April 9, 2008 Sounds like you need a quick lesson in database normalization. Theres a good link in my signiture to a free book, it has an entire chapter dedicated to the subject. If your tables are normalized properly, data can grow indefinately without the need to restructure. Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/#findComment-512660 Share on other sites More sharing options...
darkhappy Posted April 9, 2008 Author Share Posted April 9, 2008 Sounds like you need a quick lesson in database normalization. Theres a good link in my signiture to a free book, it has an entire chapter dedicated to the subject. If your tables are normalized properly, data can grow indefinately without the need to restructure. OOOOOOOOOHhhhhhhhhhhh...... so instead of creating a certain # of fields across 1 table ahead of time, you just create new tables as needed and link the associated fields with an ID - is that right? Link to comment https://forums.phpfreaks.com/topic/100256-getting-post-data-from-multiple-select-list-new-topic/#findComment-512979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.