Can you convert it all to one DB Query? Then display the results Using the GROUP attribute of the CFOUTPUT tag.
-----Original Message----- From: Samantha Brinkley [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 27, 2005 1:15 PM To: CF-Talk Subject: Accounting for Unknown Number of Loops Hi there. What would be the most efficient way for allowing an unknown number of loops in your code? I've got categories that can have parent categories. A category can only have (at most) one parent category, but it's very likely a category will have a parent category that has a parent category, etc. When displaying the categories in unordered list fashion, I'm not sure how best to account for the unknown number of layers. I'm first pulling all the categories whose ParentID is null. This gives me all the top-layer/parent categories. I can display those just fine. But then within each one, I'm doing: <ul> <CFOUTPUT QUERY="getCategories"> <li>#CatName#</li> <CFQUERY NAME="getSubCategories" DATASOURCE="#APPLICATION.Datasource#"> SELECT CatID, CatName FROM Categories WHERE ParentID=#CatID# ORDER BY CatName </CFQUERY> <CFIF getSubCategories.RecordCount> <ul> <CFLOOP QUERY="getSubCategories"> <li>#CatName#</li> </CFLOOP> </ul> </CFIF> </CFOUTPUT> </ul> and I'm getting stuck because after each "<li>#CatName#</li>" chunk of code, I want to run the query and loop again. But I don't know how best to do it. In the CF, in the queries, redo my database structure? Any thoughts appreciated. Thanks. Sam __________________________________ Yahoo! for Good - Make a difference this year. http://brand.yahoo.com/cybergivingweek2005/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Logware (www.logware.us): a new and convenient web-based time tracking application. Start tracking and documenting hours spent on a project or with a client with Logware today. Try it for free with a 15 day trial account. http://www.houseoffusion.com/banners/view.cfm?bannerid=67 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:227707 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

