473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1860
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that...
4
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
4
by: bobsawyer | last post by:
I've been building a series of SELECT lists that are populated dynamically using HTTPRequest. Things are going pretty well, and I've got the whole thing working flawlessly in Mozilla/Firebird....
3
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
1
by: serena.delossantos | last post by:
Trying to insert into a history table. Some columns will come from parameters sent to the store procedure. Other columns will be filled with a separate select statement. I've tried storing the...
9
chunk1978
by: chunk1978 | last post by:
hey everyone, i've been trying to solve this problem for 2 days straight, with no end in sight. i would greatly appreciate anyone's help. EXPLANATION: There are 3 Select Menus. The 1st and...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
4
by: rn5a | last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5 options are shown at any given time) allows multiple selection whereas the 2nd one allows only 1 option to be selected at a time. ...
6
by: Apaxe | last post by:
In the database i have a table with this information: key_id =1 key_desc =43+34+22+12 I want sum the values in key_desc. Something like: SELECT key_desc FROM table But the result of...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.