Ouwe rakker |
|
<?php
function buildOption($sValue, $sDisplay, $sCompare = '') {
return '<option value="' . $sValue . '"' . ($sValue == $sCompare ? ' selected="selected"' : '') . '>' . $sDisplay . '</option>'."\n";
}
$aUsers = array(1 => 'Proximus',
2 => 'Murfy',
3 => 'vinTage',
4 => 'nemesiskoen',
5 => 'Ontani');
$iSelectedUserId = 3;
?>
<select>
<?php
foreach ($aUsers as $iUserId => $sUsername)
{
echo buildOption($iUserId, $sUsername, $iSelectedUserId);
}
?>
</select>
<?php function buildOption($sValue, $sDisplay, $sCompare = '') { return '<option value="' . $sValue . '"' . ($sValue == $sCompare ? ' selected="selected"' : '') . '>' . $sDisplay . '</option>'."\n"; } $aUsers = array(1 => 'Proximus', 2 => 'Murfy', 3 => 'vinTage', 4 => 'nemesiskoen', 5 => 'Ontani'); $iSelectedUserId = 3; ?> <select> <?php foreach ($aUsers as $iUserId => $sUsername) { echo buildOption ($iUserId, $sUsername, $iSelectedUserId); } ?> </select>
|