Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
fu-meng #1
loop over flash array in cfc..
hi.
i'm passing a simple array from flash to a cfc and trying to understand how to
loop over it using an index loop to make my sql inserts. i just don't know the
proper way to loop over the array. here's the basic format of my array from
flash:
myArray = ["one", "two", "three'];
what i want to do is insert each element of this array into a separate field
in my table.
and this is what i'm doing in the cfc:
any help on how to just get started is very much appreciated. thank you.
<cffunction name="logStuff" access="remote">
<cfargument name="myArray" type="array" required="yes">
<cfset mLen = ArrayLen(myArray)>
<cfloop index="i" from="0" to="#mLen#">
<cfquery name="logStuff" datasource="myDB">
INSERT INTO myTable( id,
subject,
body,
field1,
field2,
field3 )
VALUES ( '??',
'??'',
'??',
'??',
'??'
'??')
</cfquery>
</cfloop>
</cffunction>
fu-meng Guest
-
loop through array to build a new array
If I combine the following 2 functions (accesses by clicking a checkbox), as result the new array does not contains all items that matches the... -
cannot loop the array
I have 2 questions regarding arrays: 1) we need to define the size of the array, there is no dynamic array concept? i.e. the following define the... -
Array Loop
Please help me to debug: <cfquery name="qSelectPwd" datasource="#Application.AppDSN#"> select password from tablename </cfquery> <!---... -
if/loop/array question
I'm trying to display an add or delete button dependent upon logged in user and I can't figure it out. Can someone please help with the... -
array data matches but array created in loop doesn't work
I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' =>... -
fu-meng #2
Re: loop over flash array in cfc..
update: i'm able to pull one of the items in my array but the problem is that i
have 3 elements in my array and only 1 record is being created in my database.
here's my updated code:
<cffunction name="logStuff" access="remote">
<cfargument name="myArray" type="array" required="yes">
<cfset mLen = ArrayLen(myArray)>
<cfloop index="i" from="0" to="#mLen#">
<cfquery name="logStuff" datasource="myDB">
INSERT INTO myTable( id,
subject,
body,
field1 )
VALUES ( 'id',
'subject',
'body',
'#arguments.myArray[i]#' )
</cfquery>
</cfloop>
</cffunction>
fu-meng Guest
-
fu-meng #3
Re: loop over flash array in cfc..
got it. i was overwriting a key in my database and that was causing problems. my cf code was correct.
thanks for following along.
fumeng.
fu-meng Guest



Reply With Quote

