Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Categories tree

Status
Not open for further replies.

prijshost

ISP
Joined
Feb 20, 2004
Messages
2
Location
BE
I have 2 tables:

Table categories: fields: categories_id, parent_id
Table categories description: fields: categories_id, categories_name.

Is there a way to display these in a tree? for example

Main cat 1
|->subcat 1
|->subcat 2
Main cat 2
| subcat 3

I don't want to use javascript, because this takes too long to generate te tree.

I HAVE to use 2 tables. I can't use one table.

Help appreciated.



 
I assume that you have a value which can appear in categories.parent_id which indicates the category has no parent. I further assume that value is 0 and that category IDs start at 1.

You'll have to do this with two queries in nested loops.

First, perform a query to fetch those category IDs and names that nave no parents.

Then loop through that query's result set, for each category creating programmatically another query to fetch that category's children.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top