Sure. In your example, though, my concern would be that other than the order in which you've listed the items, there's no way to tell which element lower than level 1 is a child of which other element. Do you have a parent ID field or some such that relates an item to its parent item or are you relying on the query returning things in the proper order? The latter seems iffy to me.
But, if you have a way of knowing, then you could use simple recursion to build your list: Loop over each level 1 item, find its children and loop over them to find their children and loop over them, etc. Doesn't matter how many levels deep except with respect to performance. Quick pseudo-code: FUNCTION buildNestedList ( [parent] ) get elements of the specified parent (default to no parent) FOR each element write "UL" write "LI" write element title IF element has children call buildNestedList ( currentElement ) END IF write "/LI" write "/UL" END FOR END FUNCTION This was done very quickly, but may give you enough to work with. On 6/6/06, Everett, Al (NIH/NIGMS) [C] <[EMAIL PROTECTED]> wrote: > Okay, I know that this should be relatively simple, and, in fact, in a > previous job I did something similar, but I cannot for the life of me > figure out how to do it. > > My query result looks like this: > > LVL TITLE > 1 Title1 > 2 Subtitle1 > 1 Title2 > 1 Title3 > 2 Subtitle2 > 2 Subtitle3 > 3 Subsubtitle1 > 1 Title4 > > And I want to turn it into this: > > <ul> > <li> > Title1 > <ul> > <li>Subtitle1</li> > </ul> > </li> > <li> > Title2 > </li> > <li> > Title3 > <ul> > <li>Subtitle2</li> > <li> > Subtitle3 > <ul> > <li>Subsubtitle1</li> > </ul> > </li> > </ul> > </li> > <li> > Title4 > </li> > </ul> > > > The data doesn't support a "level" higher than 3, so the list cannot > nest further than that. > > Anybody ever done anything similar? > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:242653 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54