[eluser]Grind[/eluser]
The user guide says this:
Code:
<select name="myselect">
<option value="one" <?php echo set_select('myselect', 'one', TRUE); ?> >One</option>
<option value="two" <?php echo set_select('myselect', 'two'); ?> >Two</option>
<option value="three" <?php echo set_select('myselect', 'three'); ?> >Three</option>
</select>
That would be fine, but in my case all the data is selected out of a database:
Code:
$options = array('one', 'two', 'three');
$default_value = 'one';
echo '<select name="myselect">';
foreach($options as $value)
{
echo '<option value="'.$value.'" '.set_select('myselect', $value).'>'.$value.'</option>';
}
echo '</select>';
In this case, how can I select the option that's equal to $default_value if no form is submitted? If form submitted, the submitted option must be selected.
Hope this makes it a little bit clearer.