Page 1 of 1

array of select (show selected)

Posted: Wed May 18, 2005 1:18 pm
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....

Posted: Wed May 18, 2005 1:20 pm
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>