View Full Version : Multiple Tier System

05-14-2007, 05:50 PM
Hi Guys,

First post here on CodingForums, so I'll say hi!!

I wonder if someone could give me a little help on a problem I have. I've been asked if I can design a directory website. I have created directory sites before with only 3 levels. E.G. Directory > Plumbers > (Business Name).

However for the site I'm building now I need to be able to add as many levels as I need, in any category. Usually what I do is create a table for each 'level' needed, then link them together.

What would be the best way to achieve what I'm after here? I was wondering about creating an ASP page that creates a table but then I don't know how to control the table from the admin control panel. This is because I cant choose which table the recordset displays.

I'm really puzzled on this one and I would be very grateful if someone could give me some help.

Many thanks in advance,

05-14-2007, 05:58 PM
By the way I'm using ASP VB and MySQL if anyone is wondering.

Please don't hesitate to ask for more information if you need it.

05-15-2007, 05:47 PM
I think you would need to have a table of "levels" and each level has a parent level (null for no parent?), which would need to be searched recursively I suppose (I don't know if mysql has any way of doing this recursive lookup directly in the sql easily, I know sql server can and microsoft access can't but those are all I have tried) You may not actually need the recursion if you only need to see what is 1 level underneath the level you are currently looking at.

Then you can have your standard table that lists the contents of each thing by the level it is in and all the information you need.

For example you could have
Levels (Name, Parent):
Directory, NULL
Builders, Directory
Plumbers, Builders
Carpenters, Builders

Contents (Name, Level, Telephone Number)
Some Plumber, Plumbers, 01234 567 890
Some Builder, Builders, 00000 111 222

05-16-2007, 03:40 PM
It depends on how you structure your database

Here is an example of a recursive menu system

05-18-2007, 02:08 PM

Thanks for your replies, I have built a database with two tables. They currently look like:

ID | ParentID | Type | Name | Description

ID | CatID | Name | Other Listing Info....

Ok so I have my two tables, one Levels has been populated with some info. Problem is I cannot seem to be able to Get the directory working properly. I have a main category page which lists the main cats, then when clicked on takes you to the sub page which at the same time passes the ID of the cat so that the subcats can be displayed.

When I click the sub category I have made it so it passes the SubcatID to yet another page which displays the subcats of the subcat. Now from this page I should be able to then click all the subcategories I need, and go however deep I need to.

Problem is, all the parent ID's are the same, which only display on one page.

I'm really confused about all this, can someone please help me? My brain is fried :(

I've included a screenshot of the categories table.