I am trying to use an insert query in my cfloops.
I started out with this code that displays the values to the page. It works just fine. Now I wanted to modify it to include an insert query that sent the data to a database
So i tried putting an insert query in and it does not work.
When I enter 3 rows of data on my form i wanted it inserted into the table in 3 differant rows.
Any help would be greatly appreciated.
I started out with this code that displays the values to the page. It works just fine. Now I wanted to modify it to include an insert query that sent the data to a database
Code:
<cfset j = #total_count#>
<cfloop index = "RowCount" from = "1" to = #j#>
<cfloop index="ColumnCount" from = "1" to = "3">
<cfoutput>#Evaluate("txt" & ColumnCount & "Row" & RowCount)#</cfoutput>
</cfloop><br><br>
<cfset j = j + 1>
</cfloop>
Code:
<cfset j = #total_count#>
<cfloop index = "RowCount" from = "1" to = #j#>
<cfloop index="ColumnCount" from = "1" to = "3">
<cfquery name="add_asset" datasource="#conn#">
INSERT INTO asset (item_num, manuf, model_num)
VALUES('#item_num#', '#manuf#', '#model_num#')
</cfquery>
<cfoutput>#Evaluate("txt" & ColumnCount & "Row" & RowCount)#</cfoutput>
</cfloop><br><br>
<cfset j = j + 1>
</cfloop>
Any help would be greatly appreciated.