Hi guys, I am attempting to create a limitless level category system.
This is what I have so far... Calling page... <cfoutput> #application.category.display_categories(0)# </cfoutput> Cfc... <cffunction name="get_categories" output="false" access="public" returntype="query"> <cfargument name="parent_id" type="numeric" required="no"> <cfargument name="cat_id" type="numeric" required="no"> <cfquery name="getCats" datasource="#variables.dsn#" username="#variables.dbusername#" password="#variables.dbpassword#"> SELECT * FROM categories WHERE 1=1 <cfif isDefined("arguments.cat_id")> AND cat_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.cat_id#"> </cfif> <cfif isDefined("arguments.parent_id")> AND parent_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.parent_id#"> </cfif> </cfquery> <cfreturn getCats /> </cffunction> <cffunction name="display_categories" output="true" access="public"> <cfargument name="parent_id" type="numeric" required="yes"> <cfargument name="level" type="numeric" default="0"> <cfif arguments.level EQ 0> <cfset variables.output = ""> </cfif> <cfset getCategories = get_categories(parent_id=arguments.parent_id)> <cfloop query="getCategories"> <cfset variables.output = variables.output & " <table width='640' border='0' cellspacing='0' cellpadding='5'> <tr> <td>#getCategories.cat_title#</td> <td width='50'><div align='center'><a href='index.cfm?action=product_manager&page=editCat&cat_id=#getCategories.ca t_id#'>Edit</a></div> </td> <td width='50'><div align='center'><a href='index.cfm?action=product_manager&page=categories&step=delete&cat_id=#g etCategories.cat_id#' onClick='GP_popupConfirmMsg('Are you sure you wish to delete the category #getCategories.cat_title#? This action cannot be undone.');return document.MM_returnValue'>Delete</a></div> </td> </tr> </table> #arguments.level# ID:#getCategories.cat_id# "> <cfif isNumeric(getCategories.cat_id)> <cfset variables.output = variables.output & display_categories(parent_id=getCategories.cat_id,level=arguments.level + 1)> </cfif> </cfloop> <cfreturn variables.output /> </cffunction> The recordset is not returning the heirarchy correctly however. Can anyone see what (big) mistakes I am making?? Thanks heaps. mike ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:289060 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4