Page 1 of 1

Drop Down Menu HELP

Posted: Wed Jun 18, 2008 12:42 am
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:

Re: Drop Down Menu HELP

Posted: Wed Jun 18, 2008 1:00 am
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.

Re: Drop Down Menu HELP

Posted: Wed Jun 18, 2008 2:38 am
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????