drop down blank?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ninja
    New Member
    • Jan 2007
    • 1

    #1

    drop down blank?

    Hi I am new to PHP and I have a little problem

    I have created a user registration form and on this form I have three drop downs one for title, prov/state and country. This creates a record in the database but when I create an edit user profile page and display the record I have a problem the record displaying correctly and I have tested the output but I cannot get the dropdowns to display the variable from the database



    <select name="title" size="1" id="label">
    <option selected="selec ted" value="Mr"><?ph p if (isset($_POST['title'])) {echo $_POST['title'];} else {echo "Mr";} ?></option>
    <option value="Mrs">Mrs </option>
    <option value="Ms">Ms</option>
    <option value="Dr">Dr</option>
    </select>

    And I have the record being read from the database but the dropdown are always blank! I have tried to put the variable in the selected value but then when I submit the form it fails saying the field is empty (even though it is in the field)

    My question is how can I display the record from mysql in drop downs and have it work when I submit the form after user has edited that field

    Thank you
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    Your code snippet does not show uw how you get your data from the database, nor does it show anything that looks like populating it with db values.
    Please show all the code that gets the data from the db. (enclose code within php, code or html tags!!)

    Ronald :cool:

    Comment

    Working...