I am in the middle of a large project doing the same sort of stuff -
Grouping Companies by Category - And I am using the approach Adrian offers.

So - on adding a new business - the code is  like so...
Step One - Add "business"
<cfquery datasource="#Application.DSN#" username="#Application.username#"
password="#Application.password#">
  INSERT INTO Businesses
        Whatever DATA HERE
</cfquery>

<!--- Now Get That Business --->
        <cfquery name="qryGetNewBusiness" datasource="#Application.DSN#"
username="#Application.username#" password="#Application.password#"
maxrows="1">
                SELECT * 
                FROM Businesses 
                ORDER by BusinessID DESC
                </cfquery>
        <cfset NewBusinessID = "#qryGetNewBusiness.BusinessID#">


<!--- Then I insert the Categories--->
<cfparam name="FORM. Categories " default="">
<cfset myList = "#FORM.Categories#">

<cfloop  list="#myList#" index="i" delimiters="," >
                                <!--- Make the changes in the form --->

                                <cftransaction>
                                <cfquery datasource="#Application.DSN#"
username="#Application.username#" password="#Application.password#">
                                INSERT INTO BusinessCategories   
                                                (CATID,BusinessID) 
                                VALUES ('#i#','#NewBusinessID#'
                        )
                                </cfquery>
                                </cftransaction>
</cfloop>


AND the form element is a loop of the catories table:

    <cfloop query="qryGetCategories">
    <cfoutput>
    <li><input type="checkbox" value="# qryGetCategories.CatID#"
name="Categories" />qryGetCategories.CatName#</li>
    </cfoutput>
    </cfloop>

I hope that helps... (When editing - - make sure you delete all references
FIRST, then add them again - to erase/overwrite any pre-existing
categories...)

- Nick



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4696
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15

Reply via email to