Creating drop down lists

Creating drop down lists

am 10.03.2007 12:33:37 von scott

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 "

";

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

RE: Creating drop down lists

am 10.03.2007 15:45:19 von Bastien Koert

close

$query = mysql_query("SELECT root FROM training");
echo "";

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
>To: php-db@lists.php.net
>Subject: [PHP-DB] 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 "";
>
>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

Re: Creating drop down lists

am 11.03.2007 03:29:59 von Manuel Lemos

Hello,

on 03/10/2007 08:33 AM Scott said the following:
> 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.

You may want to take a look at this forms generation class that comes
with a plug-in to link two or more select inputs just like you describe.

When the value of an select input changes, it triggers the switch of
options of the following select input depending on the value of the
previous select input.

There is a variant of that plug-in that retrieves the new options from a
MySQL database. It uses AJAX requests to avoid reloading the current page.

http://www.phpclasses.org/formsgeneration

Here is an example of the linked select input plug-in in action:

http://www.meta-language.net/forms-examples.html?example=tes t_linked_select

Here is a video tutorial with a section specifically about this plug-in:

http://www.phpclasses.org/browse/video/1/package/1/section/p lugin-linked-select.html

--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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

Re: Creating drop down lists

am 11.03.2007 21:21:04 von Bruce Cowin

Your select is only selecting the field 'root' but then you're trying to =
get the field 'username' in your while loop. So, you can add username to =
your select (or change it to *):

select root, username from training
select * from training



Regards,

Bruce

>>> Scott 11/03/2007 12:33:37 a.m. >>>
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 =3D mysql_query("SELECT root FROM training");
echo "";

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

--=20
AOL IM: Jestrix1

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

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