Drop Down Menu HELP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
megajuz3003
Forum Newbie
Posts: 2
Joined: Wed Jun 18, 2008 12:31 am

Drop Down Menu HELP

Post by megajuz3003 »

Hey guys, new to this forum and not the best with php or mysql however i am having problems with a site that i have been employed to fix and i need some help
:banghead:
i need to have dynamic drop down menus which in themselves are easy however my delima is that i have two menus and the second one needs a filter from the first menu

Menu One lists all the Regions from a table called Region

Menu two should list Hotels from the region that was selected in Menu One

the database layout is

Region Table:
RegionID
CountryID
Region

Hotel Table
SiteID
Site Name
Region ID
Country ID

any help would be appreciated or even base code layout :wink:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Drop Down Menu HELP

Post by Christopher »

To create the Region menu do:

Code: Select all

SELECT * FROM Region
To get the value passed by the form do:

Code: Select all

$region = intval($_POST['region'];    // assuming the form field has name="region"
To create the Hotel menu do:

Code: Select all

SELECT * FROM Hotel WHERE RegionID=$region
PS - You don't really need CountryID in the Hotel table. Usually you would normalize your database to remove the duplication. You can always get the country for a hotel by joining the two tables.
(#10850)
megajuz3003
Forum Newbie
Posts: 2
Joined: Wed Jun 18, 2008 12:31 am

Re: Drop Down Menu HELP

Post by megajuz3003 »

[quote="arborint"]To create the Region menu do:

Code: Select all

SELECT * FROM Region
To get the value passed by the form do:

Code: Select all

$region = intval($_POST['region'];    // assuming the form field has name="region"
To create the Hotel menu do:

Code: Select all

SELECT * FROM Hotel WHERE RegionID=$region
quote]

That looks good, umm that $Region = intval...... is that run by the form under the ACTION heading (dreamweaver), if that is the case i need to run a 2nd form, dreamweaver wont let me run 2 forms :banghead:

have you got anymore advice????
Post Reply