Well, I did a similar system for my CMS sollution. If I understand you correct you want to sort the main branch, keeping the subs. The sorting was in my case the part that I spent most of the time coding. The other part, selecting the subs I did really simple. As a main rule, I only select the main branch and order them, as a sub query I check if there are pages assigned to this branch. If so - present an icon to open the branch with a link link ?branch=999 Lets loop over this again with some more logic, if the $_GET["branch"] corresponds with the branch currently in the result set im looping through ill print out the results, we also include a branch close icon with reverse effect, why this is explained below. Else, I skip this and continue with the next branch. Whats bad with this? Only 1 branch can be opened at a time, so what you do is assign the branch variable to the session. Push the variable into an array, and if the branch from the current result set is in the array open it. This way we can keep track of unlimited branches, opened and closed. Together with the close function they get wiped from the array and therefore closes. Hope this helps, maby its was just swada.. :) -- -- Kim Steinhaug ---------------------------------------------------------------------- There are 10 types of people when it comes to binary numbers: those who understand them, and those who don't. ---------------------------------------------------------------------- www.steinhaug.com - www.easywebshop.no - www.webkitpro.com ---------------------------------------------------------------------- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php