Select box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Jones

    Select box

    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_nam e".

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

    $query = ("SELECT school_name FROM school_info where county_name =
    '".$county)."'" ;
    $result = mysql_query($qu ery);
    if (!$result)
    {
    echo "Error performing query: ";
    echo mysql_error();
    }
    echo "<b>School</b>&nbsp;&nbsp;& nbsp";
    echo "<select name=\"school\" >";
    while(list($sch ool_name)=mysql _fetch_array($r esult))
    {
    $school_name = stripslashes($s chool_name);
    echo "<option value=\"school_ name\">$school_ name</option>";
    }
    echo "</select>";
  • rush

    #2
    Re: Select box

    "Michael Jones" <michaelraymond _2000@yahoo.com > wrote in message
    news:21aad895.0 408020916.1d910 f9a@posting.goo gle.com...[color=blue]
    > 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_nam e".[/color]

    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,

    rush
    --



    Comment

    • Michael Jones

      #3
      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?

      "rush" <pipa@rush.aval on.hr> wrote in message news:<cem00e$fl 7$1@ls219.htnet .hr>...[color=blue]
      > "Michael Jones" <michaelraymond _2000@yahoo.com > wrote in message
      > news:21aad895.0 408020916.1d910 f9a@posting.goo gle.com...[color=green]
      > > 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_nam e".[/color]
      >
      > 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,
      >
      > rush[/color]

      Comment

      • Chris

        #4
        Re: Select box

        On 3 Aug 2004 07:10:59 -0700, michaelraymond_ 2000@yahoo.com (Michael
        Jones) wrote:
        [color=blue]
        >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?[/color]


        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
        fixed.

        C
        [color=blue]
        >
        >"rush" <pipa@rush.aval on.hr> wrote in message news:<cem00e$fl 7$1@ls219.htnet .hr>...[color=green]
        >> "Michael Jones" <michaelraymond _2000@yahoo.com > wrote in message
        >> news:21aad895.0 408020916.1d910 f9a@posting.goo gle.com...[color=darkred]
        >> > 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_nam e".[/color]
        >>
        >> 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,
        >>
        >> rush[/color][/color]

        Comment

        Working...