I am trying to figure out how to "cascade" or multi-tier a pulldown menu in php to access a sql database.
Ideally, after the user selects the first option, the next menu bar displays the options for the first choice, and after selected, the third menu bar displays the options for the second choice.
The resulting selection becomes the basis for the query accessing the SQL database for the results.
$sql = " SELECT * FROM users WHERE (age > $agemin) AND (age < $agemax) AND localID = $SELECTION;
There are three tables at work here:
local: localid, HQ, regionalID
regional: regionalID, HQ, globalID
global: globalid, HQ
There are 20 global IDs (1-20)
Each global ID has X number of regionalIDs associated with it (and they are alpha)
Each RegionalID has 3-6 localIDs associated with it (and they are alpha)
So, the user would select the GlobalID, which would display the Regional IDs for that Global ID, and after selecting the Regional ID, the Local IDs for that Regional ID would be displayed.
I started by making the global table values an array (it's static)
<?php
$global = array("1st","2nd", "3rd", "4th", "5th", "6th", "7th", "8th", "9th", "10th", "11th", "12th", "13th", "14th", "15th", "16th", "17th", "18th", "19th", "20th");
$5th = array ("KanNeb","SouthCal","California","NWMiss","Missou","Colorado","PacNW");
$SouthCal = array("LA","LAPas","LASDLV");
echo "<FORM METHOD=POST ACTION = results.php>";
echo "<SELECT NAME=column_name >";
echo"<OPTION VALUE=\"/\">Pick a District</OPTION>";
foreach($global as $district)
{
echo "<OPTION VALUE=\"$global\">$global</OPTION>";
}
// * BRAIN OVERLOAD BRAIN OVERLOAD **
echo "</SELECT></FORM>";
?>
**I was thinking about just making this a two tier model, but for Global ID 5, there would be 42 choices (kinda unwieldy on a screen IMHO).
If this is a newbie question forgive me; My brain hurts from searching fruitlessly on the web trying to figure it out.
Thank you.