RE: Creating drop down lists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




close

$query = mysql_query("SELECT root FROM training");
echo "<form action=something.php method=POST><select name='Field'>";
if($mysql_num_rows($result)>0){
while ($r = mysql_fetch_array($query))
{
$user = $r["username"];
echo "<option value='$user'>$user</option>";
}
}
echo "</select>";

should load the data in the select.

To link select boxes, first you need to decide on a method:

1. ajax - fire an ochange event to do an ajax call to load the next select box

2. pass the other select box data down to a javascript array and let the choices from the first select choose which array gets loaded into the next select

hth

Bastien

From: Scott <sburcky@xxxxxxxxx>
To: php-db@xxxxxxxxxxxxx
Subject:  Creating drop down lists
Date: Sat, 10 Mar 2007 04:33:37 -0700

Hi everyone!

I would like to create a drop down list with the info in my database.

I would also like to have more options so it will filter down to many
rows of data displayed then filtered down to a few rows of data that
said user is looking for.

Kind of like select a state then in the next box you can select the city.

but first thing is first.....

I have tried a few things out there that I searched for but everything
I tried it will not populate the drop down list with the data in my
database.

So I know it somewhere along the lines of:

$query = mysql_query("SELECT root FROM training");
echo "<form action=something.php method=POST><select name=Field>";
while ($r = mysql_fetch_array($query))
{
$user = $r["username"];
echo "<option value=$user>$user</option>";
}
echo "</select>";

or something like that but nothing populates....

What is the proper code to get this done to populate and display what
I select from the drop down menu?

Say my DB name is: TUBA
My table name is: FLUTE

and I have xxx amounts of rows to filter through with three columns in
my mysql db.

Does that all make sense?

Thanks in advance!

You all rock!!

sb

--
AOL IM: Jestrix1

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


_________________________________________________________________
RealLiveMoms: Share your experience with Real Live Moms just like you http://www.reallivemoms.ca/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux