close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Associative / Multidimensional Array Help

Thread began 5/20/2009 3:35 pm by tom92909 | Last modified 5/21/2009 10:18 am by tom92909 | 1624 views | 1 replies

tom92909Beta Tester

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>
<input name="dept" type="hidden" value="LIQUOR">
<input type="submit" value="Submit" name="B1">

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.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...