Select box

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am having difficulty getting my dynamic select box to work.  It is
generating the select box just the way I want it to (displaying only
the results of my query in the pulldown), but once I select one of the
schools, the value is always "school_name".

Can someone look at the syntax and tell me where I have gone wrong?

 $query = ("SELECT school_name FROM school_info where county_name =
    $result = mysql_query($query);
    if (!$result)
    echo "Error performing query: ";
    echo mysql_error();
   echo "<b>School</b>&nbsp;&nbsp;&nbsp";
   echo "<select name=\"school\">";
      $school_name = stripslashes($school_name);
      echo "<option value=\"school_name\">$school_name</option>";
    echo "</select>";

Re: Select box

Quoted text here. Click to load it

As it happens often in life, problem is that you miss some $ ;) Instead of:

    echo "<option value=\"school_name\">$school_name</option>";

you should have:

    echo "<option value=\"$school_name\">$school_name</option>";

good luck, and a lot of $$ in the future,

-- /

Re: Select box

That did it.  Thanks!!

I don't understand why it worked, though.  It is instructing the
program to place the value of $school_name into $school_name?  You
would put a $ sign in front of a normal HTML variable.  Why do you
need to do so here?

Quoted text here. Click to load it

Re: Select box

On 3 Aug 2004 07:10:59 -0700, (Michael
Jones) wrote:

Quoted text here. Click to load it

NOt sure what you mean by HTML variable, but, in this case, you want
the contents of the variable $school_name to be substituted at this
point in your script. A variable is, as its name implies, a bit of
data that can vary. In pure HTML the values of OPTION/VALUE would be


Quoted text here. Click to load it

Site Timeline