Hello.
I have an admin form, which allows the user to add calendar items. The calendar items can have multiple "views". These views are pulled from a separate table in my sql db. I am having success with my insert statement. Data is insterted into the main table as well as the parts table. I am able to get one insert for each iteration of the loop. I am using a list loop:
<cfquery name="getCalendarID" datasource="#request.dsn#">
SELECT MAX(Calendar_ID) as LastPost
FROM calendar
</cfquery>
<cfloop list="#form.showID#" index="FormshowID">
<cfquery name="insertParts" datasource="#request.dsn#">
INSERT INTO calendarParts
(Calendar_ID, showID, dateAdded)
VALUES
('#getCalendarID.LastPost#', '#FormshowID#', GETDATE())
</cfquery>
</cfloop>
The problem is updating. How do I update a list loop? The user sees a form with a select box (so they can choose multiple options) Is it even a list loop for an update?
I tried the following, and it updated the records (let's say there were 3 records for example), but those records in question now have the same value! So, I gather I should not use a loop?????
I tried the following:
<cfquery name="getcalendar_id" datasource="#request.dsn#">
SELECT MAX(calendar_id) as newID
FROM calendar
</cfquery>
<cfloop list="#form.showID#" index="FormshowID">
<cfquery name="updateParts" datasource="#request.dsn#">
UPDATE calendarParts
SET
calendar_id='#getcalendar_id.newID#',
showID='#FormshowID#',
dateModified=GETDATE()
WHERE calendar_id = #calendar_id#
</cfquery>
</cfloop>
THANKS in ADVANCE!!!!
I have an admin form, which allows the user to add calendar items. The calendar items can have multiple "views". These views are pulled from a separate table in my sql db. I am having success with my insert statement. Data is insterted into the main table as well as the parts table. I am able to get one insert for each iteration of the loop. I am using a list loop:
<cfquery name="getCalendarID" datasource="#request.dsn#">
SELECT MAX(Calendar_ID) as LastPost
FROM calendar
</cfquery>
<cfloop list="#form.showID#" index="FormshowID">
<cfquery name="insertParts" datasource="#request.dsn#">
INSERT INTO calendarParts
(Calendar_ID, showID, dateAdded)
VALUES
('#getCalendarID.LastPost#', '#FormshowID#', GETDATE())
</cfquery>
</cfloop>
The problem is updating. How do I update a list loop? The user sees a form with a select box (so they can choose multiple options) Is it even a list loop for an update?
I tried the following, and it updated the records (let's say there were 3 records for example), but those records in question now have the same value! So, I gather I should not use a loop?????
I tried the following:
<cfquery name="getcalendar_id" datasource="#request.dsn#">
SELECT MAX(calendar_id) as newID
FROM calendar
</cfquery>
<cfloop list="#form.showID#" index="FormshowID">
<cfquery name="updateParts" datasource="#request.dsn#">
UPDATE calendarParts
SET
calendar_id='#getcalendar_id.newID#',
showID='#FormshowID#',
dateModified=GETDATE()
WHERE calendar_id = #calendar_id#
</cfquery>
</cfloop>
THANKS in ADVANCE!!!!