Thanks for everyone's help on the hash problems, I've gone and done it the
way Dave has suggested.
<!-- 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 questionID = #CheckQuestions.questionID[i]#
</cfquery>
</cfloop>
On 21/4/05 9:02 pm, "Dave Watts" <[EMAIL PROTECTED]> wrote:
>> 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!
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:203938
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