470,848 Members | 1,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

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_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 =
'".$county)."'";
$result = mysql_query($query);
if (!$result)
{
echo "Error performing query: ";
echo mysql_error();
}
echo "<b>School</b>&nbsp;&nbsp;&nbsp";
echo "<select name=\"school\">";
while(list($school_name)=mysql_fetch_array($result ))
{
$school_name = stripslashes($school_name);
echo "<option value=\"school_name\">$school_name</option>";
}
echo "</select>";
Jul 17 '05 #1
3 1785
"Michael Jones" <mi*****************@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
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".


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
--
http://www.templatetamer.com/
Jul 17 '05 #2
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" <pi**@rush.avalon.hr> wrote in message news:<ce**********@ls219.htnet.hr>...
"Michael Jones" <mi*****************@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
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".


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

Jul 17 '05 #3
On 3 Aug 2004 07:10:59 -0700, mi*****************@yahoo.com (Michael
Jones) wrote:
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?

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

"rush" <pi**@rush.avalon.hr> wrote in message news:<ce**********@ls219.htnet.hr>...
"Michael Jones" <mi*****************@yahoo.com> wrote in message
news:21**************************@posting.google.c om...
> 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".


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


Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by JT | last post: by
4 posts views Thread by Elroyskimms | last post: by
4 posts views Thread by bobsawyer | last post: by
1 post views Thread by serena.delossantos | last post: by
2 posts views Thread by naima.mans | last post: by
4 posts views Thread by rn5a | last post: by
6 posts views Thread by Apaxe | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.