PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Thu Oct 03, 2002 9:24 pm
I am trying to get a List to work so that the user can select several of the options and it saves that as the field... anyway, here is what i got.
Code: Select all
<select name="sizes" size="3" multiple id="sizes">
<option value="XS">XS</option>
<option value="S">S</option>
<option value="M">M</option>
<option value="L">L</option>
<option value="XL">XL</option>
<option value="XXL">XXL</option>
<option value="XXXL">XXXL</option>
</select>
How would i make it so that it stores all the options selected in the following format?
Code: Select all
(say i selected : S, M, XXL)
$sizes = S, M, XXL;
Thanks!
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Thu Oct 03, 2002 9:32 pm
Code: Select all
$picked = "";
foreach($sizes as $value){
$picked .= " ".$value.",";
}
$picked = trim($picked, ",");
try something like that...
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Thu Oct 03, 2002 9:54 pm
would that be on the page that i insert it into the table?
mr_griff
Forum Commoner
Posts: 64 Joined: Tue Sep 17, 2002 11:11 am
Location: Bozeman, Montana
Post
by mr_griff » Thu Oct 03, 2002 9:56 pm
You will also need to change the name attribute in your select tag be sizes[] (<- note the square brackets) so that it will be an array after the form is submitted. Then use the code hob_goblin posted.
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Thu Oct 03, 2002 10:00 pm
alright, that works but it didn't trim that last ,
mr_griff
Forum Commoner
Posts: 64 Joined: Tue Sep 17, 2002 11:11 am
Location: Bozeman, Montana
Post
by mr_griff » Thu Oct 03, 2002 10:21 pm