1 person found this helpful
If possible, rework your heirarchy to use a nested set (left/right), rather than an adjacency list (node/parent); adjacency lists really don't scale very well, because of all the recursion one needs to do to traverse it (like how you're wanting to do). Google will turn up a bunch of stuff on this topic. There is a CF implementation of a nested set hierarchy on RIAFORGE I think.
If you can do that, have a flick through the forum posts here from the last week or two, because a very similar question to yours has been asked and answered recently. Lemme know if you can't find it, and I'll try to dig it out.
If you need to stick with adjacency lists, google "recursion examples": there'll be a stack of stuff covering your requirements already. You could probably even search these forums and dig some stuff up on "recursive" or "recursion", although the search here is a bit rubbish, so Google might be a better option.
Thanks, I didn't know that each method had a name. I found the links you were refering to. I will have to look into a nested set model. Thanks again!
(for future seekers...)
Cool. Gizza yell if you need any help with the nested set stuff.