Hi
I'm sorry .... I need help again
This time, I'm trying to build a navigation menu showing products categories with infinite levels of sub-categories.
First, I decided to use a table this way :
Then,
SELECT * FROM my_table ORDER BY cat_level, cat_name ASC
... would produce this :
It's good because the directory structure is respected but the problem is
that I also want to have all the subcategories listed in alphabetical order.
A should appear before D, F before J and B before E.
Then, I decided to change cat_level like this :
... which should output :
It looks like I've reached my 2 goals except that I also want to be able to easily retrieve the full tree directory path of any subcategory.
For example, using E, I want to output C > J > E
Using H, I want to output C > J > E > H
... and so on.
Now the problem is that this third goal seems impossible to reach with this method when it was possible with the first one.
So, my question (finally!) is : by what method could I achieve all the 3 goals?
Anyway, thanks a lot for helping !
I'm sorry .... I need help again
This time, I'm trying to build a navigation menu showing products categories with infinite levels of sub-categories.
First, I decided to use a table this way :
Code:
cat_ID | cat_level | cat_name
1 | 01.02 | A
2 | 02.02.02 | B
3 | 02 | C
4 | 01.01 | D
5 | 02.02.01 | E
6 | 02.02 | F
7 | 01 | G
8 | 02.02.02.01 | H
9 | 01.02.01 | I
10 | 02.01 | J
Then,
SELECT * FROM my_table ORDER BY cat_level, cat_name ASC
... would produce this :
Code:
G ( O1 )
D ( 01.01 )
A ( 01.02 )
I ( 01.02.01 )
C ( 02 )
J ( 02.01 )
F ( 02.02 )
E ( 02.02.01 )
B ( 02.02.02 )
H ( 02.02.02.01 )
It's good because the directory structure is respected but the problem is
that I also want to have all the subcategories listed in alphabetical order.
A should appear before D, F before J and B before E.
Then, I decided to change cat_level like this :
Code:
cat_ID | cat_level | cat_name
1 | 01.01 | A
2 | 02.02.03 | B
3 | 02 | C
4 | 01.01 | D
5 | 02.02.03 | E
6 | 02.02 | F
7 | 01 | G
8 | 02.02.03.04 | H
9 | 01.02.03 | I
10 | 02.02 | J
... which should output :
Code:
G ( O1 )
A ( 01.01 )
D ( 01.01 )
I ( 01.02.03 )
C ( 02 )
F ( 02.02 )
J ( 02.02 )
B ( 02.02.03 )
E ( 02.02.03 )
H ( 02.02.03.04 )
It looks like I've reached my 2 goals except that I also want to be able to easily retrieve the full tree directory path of any subcategory.
For example, using E, I want to output C > J > E
Using H, I want to output C > J > E > H
... and so on.
Now the problem is that this third goal seems impossible to reach with this method when it was possible with the first one.
So, my question (finally!) is : by what method could I achieve all the 3 goals?
Anyway, thanks a lot for helping !