[SOLVED]Returning Multiple Selected in Select control (Forms

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

Post Reply
mevets
Forum Newbie
Posts: 23
Joined: Fri Sep 15, 2006 10:06 am

[SOLVED]Returning Multiple Selected in Select control (Forms

Post by mevets »

I have a option control that has multiple enabled:

Code: Select all

<SELECT name="lstfriends" multiple="yes" size=5>
<?php
$friendid = explode(',', $opt['friends']);
// parse friends
foreach ($friendid as $fid) {
	echo '<option>' . $fid . '</option>';
}
?>
</SELECT>
This creates a select control that has an option for each item in an array.

When this form is submitted I check $_POST['lstfriends'] with the print_r function. The problem is that I have multiple entries selected and it only returns the last of those selected. Is there another method used to return all the entries selected?
Last edited by mevets on Wed Jun 27, 2007 9:56 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Change the name to "lstfriends[]" PHP will create an array then.
mevets
Forum Newbie
Posts: 23
Joined: Fri Sep 15, 2006 10:06 am

Post by mevets »

thanks, works
Post Reply