One approach:
$options = '';
$select_array = array('black', 'gray', 'white');
$sel_color = (isset($_POST['color']) && in_array($_POST['color'], $select_array)) ? $_POST['color'] : '';
foreach($select_array as $color){
$sel = ($sel_color == $color) : ' selected="selected"' : '';
$options .= "<option value='color'$sel>" . strtoupper($color) . "</option>";
}
...
<select name="color">
<?php echo $options;?>
</select>
diafol
Keep Smiling
10,653 posts since Oct 2006
Reputation Points: 1,628
Solved Threads: 1,510
Skill Endorsements: 57