Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Hierarchical data from MySQL
04-19-2014, 10:48 AM #1
- Join Date
- Apr 2014
- Thanked 0 Times in 0 Posts
Hierarchical data from MySQL
I don't know if I have been working for too long today but for some reason I can't seem to get my head around a particular problem. I have a set of data which is hierarchical in nature, and which I need to display as such - but there is not a set structure. For example, it may be something like this:
1. Level 1 Text 2. Level 1 Text a. Level 2 Text b. Level 2 Text i) Level 3 Text ii) Level 3 Text c. Level 2 Text 3. Level 1 Text
id | text | parent_id (default=NULL)
I'm stuck for a way to loop through the data and return it in such a way that makes traversing it relatively easy for the purposes of display and analysis, given that a given data entry may not have children and has a variable number of children.
I'm not sure if I've made myself clear or not so I can clarify if needs be. My brain is fried at this point and I can't seem to think logically around this issue.