i think it would be easier on you to use evaluate() as in...
<cfloop index="i" from="1" to="#number_of_peeps#">
 <cfquery datasource="blah">
   insert into peeps(name,age,gender)
   values(
    '#Evaluate("form.name#i#")#',
    '#Evaluate("form.age#i#")#',
    '#Evaluate("form.gender#i#")#'
   )
 </cfquery>
</cfloop>

----- Original Message -----
From: "Jeff Fongemie" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Tuesday, April 09, 2002 11:46 AM
Subject: is this even possible?? Loop using lists?


> Hello cf-talk,
>
> Is this even possible??
>
> I have a form, that collects name, age, and gender, for a list of
>   people. I get the it all as a form submission as in form.name1,
>   form.age1, form.gender1, form.name2, form.age2 and so on.
>
>   What I need to do, is create a new record in a parent table, to hold
>   some other stuff for the transaction, then add each name, age and
>   gender as a new record into a child table.  THe parent record and
>   each child record share a customerID.
>
>   The parent table is easy, but I'm having trouble getting a loop to
>   run through and insert each name,age,gender combo as a new record in
>   the child table.
>
>   This is my attempt:
>
>  <!--- set up list of names to loop through --->
> <cfoutput>
> <cfset namelist =
"#form.name1#,#form.name2#,#form.name3#,#form.name4#,#form.name5#,#form.name
6#,#form.name7#,#form.name8#,#form.name9#,#form.name10#,#form.name11#" >
>
> <cfset agelist =
"#form.age1#,#form.age2#,#form.age3#,#form.age4#,#form.age5#,#form.age6#,#fo
rm.age7#,#form.age8#,#form.age9#,#form.age10#,#form.age11#" >
>
> <cfset genderlist =
>
"#form.gender1#,#form.gender2#,#form.gender3#,#form.gender4#,#form.gender5#,
#form.gender6#,#form.gender7#,#form.gender8#,#form.gender9#,#form.gender10#,
#form.gender11#" >
>
> <!--- set up the number of items in the list so we know when to stop --->
> <cfset length=listLen(nameList)>
>
> </cfoutput>
>
>
> THEN, I INSERT to the parent table to make a new record and get a
> customerID.
>
> Now the hard part:  I'm having trouble getting a loop to use all three
> lists. Is the following even close??
>
>
>         <cfquery name="addmembers" datasource="pfestregistration"
dbtype="ODBC">
> <cfloop from="1" to="#length#" list="#namelist#">
> INSERT INTO Customers_members
>
> (customerid,
> name,
> age,
> gender,
>         address,
>         address2,
>         city,
>         state,
>         zip,
>         telephone,
>         email,
>         emergencycontact,
>         emergencynumber)
> Values
> ('#customerid#',
>
> '#namelist#',
> '#agelist#',
> '#genderlist#',
>
> '#form.address2#',
> '#form.city#',
> '#form.state#',
> '#form.zip#',
> '#form.telephone#',
> '#form.email#',
> '#form.emergencycontact#',
> '#form.contactnumber#');
>
> </cfloop>
> </cfquery>
>
>
>
> Best regards,
>  Jeff Fongemie                          mailto:[EMAIL PROTECTED]
> ------------------------
>
> 
______________________________________________________________________
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to