How bets to do this depends on your programming language and the source of the data for the select options. Ideally you will be able to loop through the options and then the code to test if the current option is selected can be written just once. e.g. (pseudocode)
while(getoption)
if({value} = {formvalue})
selected = " selected"
else
selected = ""
end if
output(<option value="{value}"{selected}>{text}</option>);
end while