You cannot create a dynamic structure selector this way. You can do something like the following to get the same result.
So, using the following data:
<cfset url.count = 3> <cfset form.entry_1 = 1> <cfset form.entry_2 = 2> <cfset form.entry_3 = 3>
Something like this will work -
<cfloop from="1" to="#url.Count#" index="i"> <cfquery name="id_#i#" datasource="xxx"> Insert Into table1(entry_level) Values(#form['entry_' & i]#) </cfquery> </cfloop>
ColdFusion basically provides you with two ways to access the value of a structure, either through a. designation or through brackets. If you are trying to access the structure using a dynamic key, you need to use parentheses.
By the way, a little better would be:
<cfloop from="1" to="#url.Count#" index="i"> <cfquery name="id_#i#" datasource="xxx"> Insert Into table1(entry_level) Values(<cfqueryparam value="#form['entry_' & i]#">) </cfquery> </cfloop>
cfQueryParam automatically escapes writing, so you donβt have to worry about SQL injection attacks. It can also make the request a little more efficient.
source share