in reply to Two recursive functions returning in unexpected order

Cool - I appear to have it working now. I pulled it out into two recursives, so the main body is now:

buildSQL($starttable, $startwhere); buildParentSQL($starttable);

I eventually found a reasonably fundamental bug - so it's possible i could have got it going the original way... But this way will be easier to maintain. And there's no way I'm touching this code anymore than i have to now!!!

Thanks for your input guys - It definately helped me find the issue. It's great to see a community of such helpful people!