
January 28th, 2005, 10:00 AM
|
|
Contributing User
|
|
Join Date: Dec 2004
Posts: 38
Time spent in forums: 6 h 43 m 17 sec
Reputation Power: 4
|
|
|
Need help looping through an insert query
I have a form that uses CFLOOP to create indexed fields of the same name for multiple entries, such as:
name1, address1, state1
name2, address2, state2
name3, address3, state3
So when the user hits the submit button, those fieldnames are passed over, but I'm having trouble looping through the insert query to add those variables to the database. Here's what I'm trying:
Code:
<CFLOOP INDEX="i" FROM="1" TO="#final_loop_cnt#">
<CFQUERY NAME="addnames#i#" DATASOURCE="#datasource#">
INSERT into name_table
(group_number,
user_name,
user_street,
user_state)
values (#newgroupnumber#, 'evaluate(name#i#)', 'evaluate(address#i#)', 'evaluate(state#i#)')
</CFQUERY>
</CFLOOP>
I've tried so many variations of that 'evaluate(name#i#)'...I've tried it with the single quotes inside ( evaluate('name#i#')), I've tried it using the formname ( 'evaluate(form.name#i#)'), I've tried it with the evaluate, without the evaulate, combinations of each, but no matter what I try, I can't get the query to recognize those variables I've passed over. What am I missing here? I don't know if this is a ColdFusion question or a database question, but any help would be, well, helpful 
|