$selected = 1; while (/** fetch sql **/) { echo '<option'. $reg['value'] == $selected ? ' selected' : '' . '>'; }