Array with nested values. Display in ul list. php html.
Posted
by
btwong
on Stack Overflow
See other posts from Stack Overflow
or by btwong
Published on 2011-03-17T00:05:13Z
Indexed on
2011/03/17
0:10 UTC
Read the original article
Hit count: 108
i have a record set returned from a data base that is looking like this:
id | level | lft | rgt | title
---------------------------------
1 | | 1 | 8 | title 1
2 | - | 2 | 5 | sub title 1-1
3 | -- | 3 | 4 | sub sub title 1
4 | - | 6 | 7 | sub title 1-2
5 | | 9 | 12 | title 2
6 | - | 10 | 11 | sub title 2
AS you can see its a hierarchy list, with left n right values.
I am trying to display this record set in a list with the correct indentation, so that it appears like this:
- Title 1
- Sub title 1-1
- Sub sub title
- sub title 1-2
- Sub title 1-1
- Title 2
- sub title 2
Any pointers to do this with the one record set? Or should i use multiple queries to display this?
© Stack Overflow or respective owner