CFLOOP multiple form variables in a cfquery insert or update.
Posted on 2006-05-25
Form variables below, QUESTIONID and QUESTION are not looping (and others not shown here for simplicity). Of course they are not because I don't know how! I've only been able to get ANSWER(answer_index) to loop. How does one loop multiple variables and INSERT OR UPDATE them into a table? (cf5 and sql2000).
<cfloop index="field" list="#structKeyList(form)#"> gives me all the variables but I have no idea how to use it in a CFQuery insert or update.
If you'd help, please modify my code so it will make some sense to this amateur. I really need help on this ASAP and will be much appreciated!
<cfloop index="answer_index" list="#form.answer#">
<cfquery name="CreateAnswerInfo" datasource="survey">
insert into survey_user_answers
questionid, <!--- this needs to loop --->
question, <!--- this needs to loop --->
answer, <!--- this is looping correctly --->
'#answer_index#', <!--- only this one loops --->