Nested loops. Outer loop is your formfields. Inner loop is each field (treat them as lists).
Thanks for the help! I am still stuck as to exactly how this will be done. My form is as follows:
and users can add another product etc so there will be more fields for each additional product (which all seem to get truncated as a comma seperated list in the form value)
Here is what I have so far, after the form is submitted:
<cfloop item="key" collection="#form#">
INSERT INTO Deals (type, price, unit, name) VALUES ('#form.type#', #form.price#, '#form.unit#', '#form.name#' )
I honestly don't use loops like this very often so I apologize for having a lack of understanding. I know you mentioned making them nested loops but I dont' know how to do it and have it successfully insert the appropriate data. Everytime I try it doesnt come out right.
Hopefully, each time the user adds a product, something is appended to the end of every form field. It becomes very easy. In fact you don't even need nested loops.
<cfloop from = "1" to = listlen(form.name) index = "i">
INSERT INTO Deals
(type, price, unit, name)
('#listgetat(form.type, i)#', #listgetat(form.price, i)#, '#listgetat(form.unit, i)#', '#listgetat(form.name, i)#' )
Also, cfqueryparam for a number of reasons.