> I've got a problem whereby I'm trying to reference my looped 
> variable in an SQL statement.
> 
>             <!-- Update the answers in the database -->
>             <cfloop index="i" from="1" 
> to="#CheckQuestions.recordCount#">
>             <cfquery name="UpdateAnswers" datasource="user020">
>             UPDATE tbl_020publicQuestions
>             SET answer = '#form.answer##i#'
>             WHERE interviewID = #CheckInterview.interviewID[i]#
>             </cfquery>
>             </cfloop>
> 
> My problem appears to be the line SET answer = 
> '#form.answer##i#' - any ideas how I can get this to work? In 
> my form I had answers put into a loop
> (answer1 answer2 answer3 etc).

You can reference form fields as structure members:

SET answer = '#Form["answer" & i]#'

However, rather than looping over a CFQUERY tag, why not put the loop inside
the CFQUERY tag so that you only have to run one query?

<cfquery ...>
UPDATE  tbl_020publicQuestions
SET             
        <cfloop ...>
        answer = '#Form["answer" & i]#
                <cfif i neq CheckQuestions.RecordCount>
                ,
                </cfif>
        </cfloop>
WHERE ...
</cfquery>

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized 
instruction at our training centers in Washington DC, Atlanta, 
Chicago, Baltimore, Northern Virginia, or on-site at your location. 
Visit http://training.figleaf.com/ for more information!


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:203898
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

Reply via email to