Norsk.Firefox Posted September 8, 2008 Share Posted September 8, 2008 Hello I have a problem now; i have a table; with ID, name and parent_id. How can I list Parent |- Child |-- Child's child Parent2 |- Child etc.. ? I have saved categories with no restrictions of how many children a category can have.. Anyone have a solution? or another way of doing it? Quote Link to comment https://forums.phpfreaks.com/topic/123231-parentchild-categories/ Share on other sites More sharing options...
JonnoTheDev Posted September 8, 2008 Share Posted September 8, 2008 You will require what is called a recursive function that starts with the top level parentId (assuming it is 0) and then changes for each database row. You need to build a multi dimensional array from the function. Quote Link to comment https://forums.phpfreaks.com/topic/123231-parentchild-categories/#findComment-636423 Share on other sites More sharing options...
aschk Posted September 8, 2008 Share Posted September 8, 2008 Please see http://www.phpfreaks.com/forums/index.php/topic,214858.msg982511.html This has been discussed before and you probably need reorganise that table before you proceed. It was discussed in depth, and i pointed out that recursive database calls are inefficient. Quote Link to comment https://forums.phpfreaks.com/topic/123231-parentchild-categories/#findComment-636443 Share on other sites More sharing options...
Norsk.Firefox Posted September 8, 2008 Author Share Posted September 8, 2008 Just what I was searching for , tnx Quote Link to comment https://forums.phpfreaks.com/topic/123231-parentchild-categories/#findComment-636446 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.