$userchoice = 'Option 2';
$results = mysql_query('SELECT * FROM options');
echo '<select name="name">\n';
while ($result = mysql_fetch_array($results)) {
if ($userchoice == $result['value']) {
$selected = ' selected="selected"';
} else {
// if we don't do this, every option after this one will be selected
$selected = '';
}
echo "<option value=\"" . $result['value'] . "\" $selected>" . $result['optionname'] . "</option>\n";
}
Basically you build the option drop-down, checking each time to see if the current value matches the user's previous selection. Instead of hardcoding it at the top, obviously you'd pull it from the database or wherever you're storing it.