Multiple choice related fields form

Dear all,

Let's say you have an on-line computer store, and you are creating an administration page so your employees can add new products to the database.

This administration page is a form with several fields. There's a name of product field, a price field, a list of areas where the new product belongs:

Hardware
Software
Games

And a list of sub areas:

Arcade games
Sport games
Tennis Games
Basketball Games
Editors
Animation software
Antivirus
Hard Drives
Precessors
Motherboards


Say that you are adding a new product using this administration and it is a game.

After filling in the name of the game and the price, you have to choose Software and Games in the areas list. Then only the sub areas related to  the  Software and Games areas  should show:

Arcade games
Sport games
Tennis Games
Basketball Games
Editors
Animation software
Antivirus

for you to choose the right sub area or sub areas .
How can I do that?

I'm thinking in a multiple select for the areas, but then how can I show just the sub areas related to the areas chosen? and then these sub areas have to be able to be selected amd submitted  with the rest of the form.

Also, how's the structure of the MySql table or tables? I still don't get how an area "understands" what is the sub area that belongs to it.

The technology  I'm  thinking of is: PHP, Javascript and MySQL

I'm lost, please help!!
Thanks in advance!
Dada44Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

amxCommented:
You should try working backwards.

Design the database tabels first, this will help you understand how the tackle the problem when you try to build the web page.

This tutorial will help you get started, it will help explain how an area knows about a sub area.

http://www.geekgirls.com/databases_from_scratch_3.htm
NerdsOfTechTechnology ScientistCommented:
TABLE CATEGORIES
=================
catID | Name
1 | Hardware
2 | Software
3 | Games

TABLE SUBCATEGORIES
====================
subID | catID | Name
1 | 3 | Arcade games
2 | 3 | Sport games
3 | 3 | Tennis Games
4 | 3 | Basketball Games
5 | 2 | Editors
6 | 2 | Animation software
7 | 2 | Antivirus
8 | 1 | Hard Drives
9 | 1 | Precessors
10 | 1 | Motherboards

PRODUCT TABLE
==============
prodID | subID | Name
1 | 3 | Street Fighter II
2 | 8 | Western Digital SATA 160GB 7200RPM 8MB Cache

See how the subCategory table references the catID (this is called a foreign key)...
Same with the product how it references the subID

In essence the connection is simplified into a 'tree' like structure
Category
 SubCategory based on catID
  Product based on subID
NerdsOfTechTechnology ScientistCommented:
CORRECTION: Street Fighter II isn't a tennis game :)

TABLE CATEGORIES
=================
catID | Name
1 | Hardware
2 | Software
3 | Games

TABLE SUBCATEGORIES
====================
subID | catID | Name
1 | 3 | Arcade games
2 | 3 | Sport games
3 | 3 | Tennis Games
4 | 3 | Basketball Games
5 | 2 | Editors
6 | 2 | Animation software
7 | 2 | Antivirus
8 | 1 | Hard Drives
9 | 1 | Precessors
10 | 1 | Motherboards

PRODUCT TABLE
==============
prodID | subID | Name
1 | 1 | Street Fighter II
2 | 8 | Western Digital SATA 160GB 7200RPM 8MB Cache

See how the subCategory table references the catID (this is called a foreign key)...
Same with the product how it references the subID

In essence the connection is simplified into a 'tree' like structure
Category
 SubCategory based on catID
  Product based on subID

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Dada44Author Commented:
NerdsOfTech I think you got it!
The thing I still cannot figure out is the query to  show just the sub areas (or sub categories) related to the areas (or categories) chosen.

Thanks a ton in advance!
NerdsOfTechTechnology ScientistCommented:
SELECT subcategories WHERE catID = Selected Category
NerdsOfTechTechnology ScientistCommented:
So if the user chooses 2 for category
SELECT subcategories WHERE catID = 2

Output:
5 | 2 | Editors
6 | 2 | Animation software
7 | 2 | Antivirus
Dada44Author Commented:
Thanks!!!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.