How to populate a table with array loop
I'm looping an array object and as I loop, I'm calling a function and this function returns 6 items
<CFLOOP from="1" to="#ArrayLen(zz)#" index="k">
<cfdump var="#zz
</CFLOOP >
The above cfdump will return something like:
[empty string]
street name1
[empty string]
[empty string]
city1
state1
zip1
[empty string]
street name2
Apartment AA
[empty string]
city2
state2
zip2
street name 3
Margenthaller Hall
Suite 202
city2
state2
zip2
etc
I need to insert these results into my address table while looping.
When I did the following (see below), each record got repeated 12 times (not sure why)
<CFLOOP from="1" to="#ArrayLen(zz)#" index="k"> <cfdump var="#zz
<cfquery name="test" datasourece="MyDNS">
INSERT INTO MyAddr (street1,street2,street3,city,state,zip)
VALUES ('#zz[1].getLine()#', '#zz[2].getLine()#', '#zz[3].getLine()#', '#zz[4].getLine()#','#zz[5].getLine()#', '#zz[6].getLine()#')
</cfquery>
</CFLOOP >
Is there a way? to do insert as I already got the address correctly while looping but not sure how can I use the return result in insert statement.
Can anyone help?
