Forum Moderators: open

Message Too Old, No Replies

Need help retrieving subdirectories...

How do I get more than one subdir to list?

         

HyperGeek

7:15 pm on Mar 24, 2004 (gmt 0)

10+ Year Member



I'm trying to create a simple directory system and cannot figure out how to list the sub directories.

Lets say I'm dealing with this table...

CATEGORIES
c_ID, c_PID, c_Name

...I can list all directories alphabetically by c_Name.
...I can also pull a subcategory according to the c_PID.

However, if that subdirectory is parent to another subdirectory, and so on, I cannot seem to figure out how to pull more than just the first one.

I'm assuming I need to LOOP something, but I can't wrap my head around this one for some reason.

Any suggestions?

Xoc

8:06 pm on Mar 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is no way to do that using simple SQL. You can do it with code. The easiest way to code it is to use recursion, but explaining recursion is non-trivial. You basically have a function that calls itself. Search on Google for recursion.

HyperGeek

8:07 pm on Apr 5, 2004 (gmt 0)

10+ Year Member



Okay I've got the first issue handled well.

A glance or two at free ASP message boards gave me what I need to know about a parent/sub structure.

Now I'm trying to figure out how to get the categories to list like this:

/directory/new_directory/other_directory

..instead of this...

directory
--> new_directory
----> other_directory

Any suggestions?