- 0
php Recursive function for tree like structure
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
- 3 answers
- 3,902 views
-
QNAP issues patch for an RCE security vulnerability affecting PHP in NAS Drive management
By Alap Naik Desai,
- remote code execution
- rce
- (and 12 more)
- 0 replies
- 10 views
-
Get this Dynamic 2022 Data & IT Security Training Bundle at 97% off
By News Staff,
- neowin deals
- cyber security
- (and 4 more)
- 0 replies
- 10 views
-
Save 98% off this 27 Course Premium Learn to Code Certification Bundle
By News Staff,
- neowin deals
- coding
- (and 10 more)
- 0 replies
- 12 views
-
Get the Complete 2021 Superstar Backend Developer Bundle for only $39.99
By News Staff,
- neowin deals
- sponsored
- (and 7 more)
- 0 replies
- 325 views
-
Question
game_over
I'm struggling to get my head around this one, i've had a few attempts and failed miserably.
Basically I have a list of categories in a database, each with an ID. A category can have a parent category.
I need to output the structure in some sort of tree
Main category
- Child 1
- Child 2
Another category
- Child 1
- Child 2
Here is a very basic structure example.
In this case, Fruit is a child of Food and Shoes is a child of Clothing.
I can manage it quite easily performing several queries but I need to do it as efficient as possible with one query and whatever is the fastest method to generate the tree like structure, either a loop or recursive function.
Any ideas?
Thanks
Link to comment
https://www.neowin.net/forum/topic/1331262-recursive-function-for-tree-like-structure/Share on other sites
1 answer to this question
Recommended Posts