Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
dorothy #1
loop over srray in structure?
Greetings - help would be greatly appreciated! I have a query that pulls
multiple id's for multiple users. I am putting the id's in an array in
structures for each user along with their email address and company name. I
then have another query pulling data for each id and emailing it to the users
for each structure. I need to loop over the id's in the array (for each
structure) in the second query. Is this possible? Am I even going about
this the easiest/right way??:confused;
dorothy Guest
-
Class::Struct - want to access structure within structure
I want to access a structure within a structure. Below is what I had in mind. Please help. #!/perl/bin/perl use Class::Struct; struct Step... -
Can a film loop play once, then loop on the last frame(s)?
I need a film loop to play once, then loop playback on the last frame so I can keep the LOOP of the film loop set. This will allow the tell commands... -
Film loop rollovers working with tell sprite, but only if Loop is checked
on mouseWithin me cursor 280 tell sprite 40 --the sprite containing the film loop sprite(60).member = member("networkmapsbuttonroll") --swapping... -
Urgent: Repeat loop and Film loop clash!
Hi All, Scenario I have a script running in which the spelling which was typed in by the student is corrected. The alphabets are moved to... -
Help with loop inside loop and mysql queries
Hi List. I cannot see my error: I have relation tables setup. main id entity_name main_type etc etc date_in 1 test type1 x y 2003-06-02... -
cf scooter #2
Re: loop over array in structure?
Hi Dorothy, can we see some code to get a better handle on what you need to do?
Is the problem that you need to loop through the array of IDs within the
<cfmail> tag? It would be helpful to see the code and where you are stuck.
cf scooter Guest
-
dorothy #3
Re: loop over array in structure?
I need to loop throught the id's in the second query. The loop in the cfmail
is working but it craps out after the first user when I loop through a list
(commented out) - and I get: Error Occurred While Processing Request You
have attempted to dereference a scalar variable of type class java.lang.Integer
as a structure with members this way........ Code:
--------------------------------------------------------------------------------
----------------------------------------- <cfquery name='contentNOTICE'
datasource='#application.ds#' dbtype='ODBC'> SELECT
..................................... FROM ................. WHERE
........................ ORDER BY user.countryid, user.user_id,
contents.contentid </cfquery> <cfoutput> <cfset user_email =
'#contentNOTICE.email#;'> #user_email# </cfoutput> <cfoutput
query='contentNOTICE' group='countryid'> #Country# <hr> <cfoutput
group='user_id'> <cfset user = StructNew()> <cfset user.ContentType =
'Country'> <cfset user.TypeData = #contentNOTICE.country#> <cfset user.email =
#contentNOTICE.email#> <cfoutput><cfset
contentList='#contentNOTICE.contentid#'></cfoutput> <!--- start array --->
<CFSET contents=ArrayNew(1)> <CFSET contents[1] = '0001'> <cfloop
index='contentid' list='contentList' delimiters=','>
<CFOUTPUT>#ArrayAppend(contents, '#contentid#')#</CFOUTPUT> </CFLOOP>
<cfset user.contentlist = contents> <CFSET myList=ArrayToList(contents, ',')>
<cfdump var=#user#> <cfquery name='getContentcontent'
datasource='#application.ds#' maxrows=25 dbtype='ODBC'> SELECT ...........
FROM..................... <!--- <cfloop list='#myList#' index='listItem'>
<Cfif #listFirst(mylist)# EQ #listItem#>AND (<cfelse>OR </cfif>
(contents.contentID = #listItem#) </cfloop> ) ---> <cfloop index='contentid'
from='1' to='#arraylen(contents)#'> <Cfif #contents[1]# EQ
#contentlist[contentid]#>AND (<cfelse>OR </cfif> (contents.contentID =
#contents[contentid]#) </cfloop> ) ORDER BY contents.contentcountryid
ASC</cfquery> <cfmail group='countryid' to='#user.email#' from='admin'
subject='#user.ContentType#' type='HTML' groupcasesensitive='Yes'> <cfloop
query='getContentcontent' startrow='1'
endrow='#getContentcontent.recordcount#'> #contentid#<br> </cfloop>
</cfmail> </cfoutput> </cfoutput>
dorothy Guest
-
cf scooter #4
Re: loop over array in structure?
I'm a little confused by this line: <cfoutput><cfset
contentList='#contentNOTICE.contentid#'></cfoutput> Because it is an inner
loop, I'm assuming that you have multiple records with different ContentIDs (as
opposed to a single record in your table that has a list of IDs) ... so,
shouldn't you be using the ListAppend() function here? Like this... <cfset
ContentList = ''> <cfoutput><cfset contentList =
ListAppend(ContentList,contentNOTICE.contentid)></cfoutput> Also, when you are
looping through this list, you need to use #'s around the list name, like
this... <cfloop index='contentid' list='#contentList#' delimiters=','> Hope
that helps, scooter
cf scooter Guest
-
Pete Thomas #5
Re: loop over array in structure?
The commented code
contents.contentID = #listItem# iswrong you previously created contents an Array so you would set a value as below
contents[listindex] = #listItem#
Pete Thomas Guest
-
dorothy #6
Re: loop over array in structure?
That line - <cfoutput><cfset
contentList='#contentNOTICE.contentid#'></cfoutput> works fine. I ended up
setting a list because I couldn't loop through the array in the structure. It
pulls everything I need for one user then on the second time through the loop I
get nothing. So..... I went back to trying to loop through the array of id's
in the structure and got the other error: Error Occurred While Processing
Request You have attempted to dereference a scalar variable of type class
java.lang.Integer as a structure with members
dorothy Guest
-
dorothy #7
Re: loop over array in structure?
There are different arrays in different structures for each user - I tried to
loop through them on the second query and get an error. Is this the correct
way to loop through an array in a structure??? <cfloop index='contentid'
from='1' to='#arraylen(contents)#'> <Cfif #contents[1]# EQ
#contentlist[contentid]#>AND (<cfelse>OR </cfif> (contents.contentID =
#contents[contentid]#) </cfloop> )
dorothy Guest
-
Pete Thomas #8
Re: loop over array in structure?
There are different arrays in different structures for each user - I tried to
loop through them on the second query and get an error. Is this the correct
way to loop through an array in a structure??? <cfloop index='contentid'
from='1' to='#arraylen(contents)#'> <Cfif #contents[1]# EQ
#contentlist[contentid]#>AND (<cfelse>OR </cfif> (contents.contentID =
#contents[contentid]#) </cfloop> ) (contents.contentID =
#contents[contentid]#) this line is incorrect u are referencing an array as a
structure
Pete Thomas Guest
-
dorothy #9
Re: loop over array in structure?
So how do I reference the array in the structure?
dorothy Guest
-
Pete Thomas #10
Re: loop over array in structure?
so a you have an array with key of 'myarray' in structure mystruct.
it would be mystruct.myarray[index] index being numeric
Pete Thomas Guest
-
dorothy #11
Re: loop over array in structure?
Ok - tried that: <cfloop index='contentid' from='1'
to='#arraylen(contentlist)#'> <Cfif #user.contentlist[1]# EQ
#user.contentlist[contentid]#>AND (<cfelse>OR </cfif> (contents.contentID =
#contents[contentid]#) </cfloop> ) and got this: Object of type class
java.lang.Integer cannot be used as an array What am I doing wrong here???
dorothy Guest
-
dorothy #12
Re: loop over array in structure?
<cfloop from='1' to='#ArrayLen(user.contentlist)#' index='i'>
#user.contentlist#<br>
</cfloop>
dorothy Guest



Reply With Quote

