Not selecting value from drop down list

Posted on 2008-11-10
Last Modified: 2013-12-13
I have created a drop down list that displays values from mysql database.  The values are displayed but when a value is selected it no value is present.  Using html form.  Here is the drop down code:

echo "<select name=location value=''>Location</option>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[id]>$nt[location]</option>";
/* Option values are added by looping through the array */
echo "</select>";// Closing of list box

When I output Location in program that is called by form it is empty.
Question by:tpiccirillo
    LVL 16

    Expert Comment

    How does the html output look like?

    Try surrounding the $nt[id] by (double) quotes.
    LVL 15

    Accepted Solution

    If you have checked the generated source code and see no problem with the select and option (with correct option values) html code, the problem may be from your output program.

    Author Comment

    Out put program is working okay for other fields.  Just nothing in this field that is dynamically created.
    LVL 16

    Assisted Solution

    Can you try to remove value part in the select tag and change it to:

    echo "<select name=location>";
      echo "<option value=$nt[id]>$nt[location]</option>";
    echo "</select>";

    Open in new window


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now