Setting a default value in a
<?
$sweets = array('puff' => 'A',
'square' => 'C',
'cake' => 'B',
'ricemeat' => 'S');
print '<select name="sweet">';
foreach ($sweets as $option => $label) {
print '<option value="' .$option .'"';
if ($option == $defaults['sweet']) {
print ' selected="selected"';
}
print "> $label</option>\n";
}
print '</select>';
?>
Related examples in the same category