php - HTML select default value from database -
i trying add html "select dropdown list
" gender. want default value database php framework. can that?
pseudo code:
$default_gender = getdefaultgendervaluefromdb; <select name="genderselected"> <option value="m"<?php echo ($default_gender == 'm')? selected:'';?>>male</option> <option value="f"<?php echo ($default_gender== 'f')? selected:'';?>>female</option> </select>
valid code snippet:
<?php $default_gender = 'm'; ?> <select name="genderselected"> <option value="m" <?php echo ($default_gender == 'm')? 'selected="selected"':'';?>>male</option> <option value="f" <?php echo ($default_gender == 'f')? 'selected="selected"':'';?>>female</option> </select>
Comments
Post a Comment