return selected field for drop down list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yousef Altaf
    New Member
    • Jun 2011
    • 22

    return selected field for drop down list

    I want if the user clicks submit to return the the selected value when the form reloads

    that what I try and no luck

    Code:
        <?php
        $getData = $db->prepare("SELECT * FROM first_university_degree_list");
        if ($getData->execute()) {
        $res = $getData->get_result();
        while ($data = $res->fetch_array()) {
        ?>
        <option value="<?php echo $data['univ_degree']; ?>" <?php if($FirstUniversityDegree == $data['univ_degree']) echo 'selected="selected"'; ?>><?php echo $data['univ_degree']; ?></option>
        <?php
        }
        }
        ?>
    clearing the question
    I have a validation for every field on the form so if any of this fields return false the options on the drop menu will return to the first item I need it to return on the selected item the users selected
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you need to set the selected property for the option that holds the value the user has posted.

    Comment

    Working...