> Is it possible to create multiple lists in a CFLOOP that
> would allow me to insert several lists into a couple of columns?
> I know it is possible with one.
> ie,
> <CFLOOP INDEX="thisimportance",
> LIST="#form.imp1#,#form.imp2#,#form.imp3#>
> <cfquery datasource = "whatever">
> INSERT into testing (Importance)
> VALUES ('#thisimportance#')
> </cfquery>
> </CFLOOP>
>
> But how would it work if I wanted to insert the following
> lists into the corresponding fields?
> ie,
> list- "#form.imp1#,#form.imp2#,#form.imp3# into column (Importance)
> list- "#form.place1#,#form.place2#,#form.place3# into column (Place)
> list- "#form.comments1#,#form.comments2#,#form.comments3# into column
> (Comments)
>
> The reason I ask if it's possible to do all this with one INSERT
> command is that I need #form.imp1#, #form.place1#,and #form.comments1#
> to enter as a single record in the DB so that the output would look like;
> (importance)1---- (place)Ontario, (comments)Is nice
> etc.
You can do this by tracking the number of records you want to insert,
looping over that number, and using Evaluate within your loop:
<CFLOOP INDEX="i" FROM="1" TO="#NumberOfRecords#">
<CFSET MyImp = Evaluate("Form.imp" & i)>
<CFSET MyPlace = Evaluate("Form.place" & i)>
<CFSET MyComments = Evaluate("Form.comments" & i)>
<CFQUERY NAME="qInsItem" DATASOURCE="myds">
INSERT INTO testing
(imp, place, comments)
VALUES
('#MyImp#', '#MyPlace#', '#MyComments#')
</CFQUERY>
</CFLOOP>
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.