array of select (show selected)

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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

array of select (show selected)

Post by Burrito »

having a brain failure I am. Figure this out right now I can not...

have the following code for a select I do:

Code: Select all

<select name="uid[]" size="5" multiple="multiple">
<?
while($gtusers = mysql_fetch_assoc($getusers)){
?>
<option value="<?=$gtusers['id'];?>" <?=(isset($_POST['uid']) && $_POST['uid'] == $gtusers['id'] ? "selected=\"selected\"" : "");?>><?=$gtusers['username'];?></option>
<?
}// end while for result set...burrito 
?>
</select>
need to show all of the options selected I do when submitted is the form. need to strip out of the array all of the values I do, know how I do not right now....
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

nevermind, figured this out I did:

Code: Select all

<select name="uid[]" size="5" multiple="multiple">
<?
while($gtusers = mysql_fetch_assoc($getusers)){
?>
<option value="<?=$gtusers['id'];?>" <?=(isset($_POST['uid']) && in_array($gtusers['id'], $_POST['uid']) ? "selected=\"selected\"" : "");?>><?=$gtusers['username'];?></option>
<?}// end while for result set...burrito ?>
</select>
Post Reply