Associative / Multidimensional Array Help
I have an Associative or Multidimensional Array question that I've spent most of the day working on and I haven't managed to make much progress.
I have a MySQL Table that contains inventory related information on specific items.
The fields that I'm wanting to manipulate for reporting purposes are listed below.
To categorize each individual record, each row will have one of the dept/subdept combinations.
+----------------+
| Dept | Subdept |
|----------------|
|WINE | 1 |
|WINE | 2 |
|WINE | 3 |
|WINE | 4 |
|WINE | 5 |
|WINE | 6 |
|WINE | 7 |
|WINE | a |
|WINE | b |
|WINE | c |
|WINE | d |
|WINE | e |
|WINE | f |
|WINE | g |
|WINE | h |
|LIQUOR| 0 |
|LIQUOR| 1 |
|LIQUOR| 2 |
|LIQUOR| 3 |
|LIQUOR| 4 |
|LIQUOR| 5 |
|LIQUOR| 6 |
|LIQUOR| 7 |
|LIQUOR| 8 |
|LIQUOR| 9 |
+----------------+
Sample Data Explained:
------------------------
Wine,1 = Chardonnay
Wine,2 = Sauvigon Blanc
Wine,c = Syrah
Liquor,3 = Tequila
From a web form (preceding page), I am posting a Dept name and a Sub Dept ID to a PHP results page.
<form action="results.php" method="POST">
<select size="1" name="subdept">
<option value="3">Tequila</option>
</select>
<input name="dept" type="hidden" value="LIQUOR">
<input type="submit" value="Submit" name="B1">
</form>
My results.php page has the following MySQL
SELECT * FROM `inventory`
WHERE `Dept` = '".$_POST['dept']."' AND `Dept_no` = '".$_POST['subdept']."'
I want to make the Sub Department and the Wine Descriptions to display as text like in the following Array that I have created.
$name = array("LIQUOR"=>array(
"Vodka", "Gin", "Tequila", "Rum", "Brandy & Cognac", "Cordials", "Bourbon", "Canadian Whiskey", "Scotch Whiskey", "Irish Whiskey"),
"WHITE WINE"=>array(
"Chardonnay", "Sauvignon Blanc", "Riesling", "Viognier", "Pinot Gris", "Champagne", "Sparkling"),
"RED WINE"=>array(
"Cabernet Sauvignon", "Merlot", "Syrah", "Shiraz", "Pinot Noir", "Zinfandel", "Grenache", "Chianti"));
*** The Point of the Post ***
My problem is that I have no idea how to implement this to display Tequila on my results page from my form in this example. My example is hard coded to display LIQUOR, but that won't always be the static dept.
Ok, I think that is clear as mud.
Your comments and recommendations are welcome.
Thanks in advance for your comments and time.