Variable within a Variable
I have a form that allows the user to create 5 different sets of results on the same form. I do this by using CFLoop. For example:
<cfloop from=”1” to=“5” Index=“i”>
Form FieldName#i#
So I end up with:
FieldName1
FieldName2
FieldName3
FieldName4
FieldName5
That part works great and keeps the form code short and clean considering there are 16 form fields.
Is there a way to loop over that data to insert it into a table. Each Index needs to be its own row in the table. For example…
<cfloop from=”1” to=“5” Index=“z”>
<cfquery datasource = “abc”>
Insert into XYZ (Name)
Values (#form.FieldName[z]#)
</cfquery>
What I don’t know how to do is use a variable (the index) within a variable (Form.Result). Parts of the form need to go into 6 different tables times 5 sections of the form would be 30 SQL statements vs. 6 if I can loop.
Thanks in advance for any assistance.
Gary
