Question
Checkboxes and INSERT/UPDATE - help!!
I have 3 tables (locations, categories, location_categories)
I need to do an update and insert. Here are the three selects which
retrieves the checked categories. How can I do an insert / update
into the locations_categories table creating a record for each
checkbox that is checked. I know I need to do a loop on a list but
not sure how to write it. Here are my select statements.
<cfquery name="getlocations">
SELECT locationid, locname
FROM locations
</cfquery>
<cfquery name="getcategories">
SELECT categoryid, catname
FROM categories
</cfquery>
<cfquery name="loccatselected">
SELECT
categoryid
FROM location_categories
WHERE locationid=#URL.locationid#
</cfquery>
<cfset variables.selectedCategories=ValueList(loccatselected.categoryid)>
<cfquery name="getlocations">
SELECT locationid, locname
FROM locations
</cfquery>
<cfquery name="getcategories">
SELECT categoryid, catname
FROM categories
</cfquery>
<cfquery name="loccatselected">
SELECT
categoryid
FROM location_categories
WHERE locationid=#URL.locationid#
</cfquery>
<cfset variables.selectedCategories=ValueList(loccatselected.categoryid)>
