• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Looping over Nested Structure

Guest
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

Hey Guys,
I have a component that returns a structure. The structure is called ContactQuery. ContactQuery has to elements, one called Results, and one called Success. Results contains the data I want to loop over. If you try looping over the ContactQuery by using CFLoop and specify the ContactQuery as the collection, of course it only loops twice (once for Results, once for Success). How can I loop over the Results structure withing ContactQuery? You can see the dump of the structure at:
http://www.digitalswordsmen.com/cfschedule/admin/Create_Tokens_Table.cfm

Attached is the code I have. I am just unsure of the syntax for looping over the Results section of the structure.

Thank you.
TOPICS
Advanced techniques

Views

653

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jan 01, 2009 Jan 01, 2009
It looks like it is query. Did you try a regular query loop?

<cfloop query="ContactQuery.Results">
...
</cfloop>

Votes

Translate

Translate
Valorous Hero ,
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

Try using ContactQuery.Results instead of ContactQuery. Though it is not clear whether "Results" is a structure or a query object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

Thanks for the quick reply.
Using
<cfloop collection="#ContactQuery.Results#" item="i">
Yields and error. I did try that first, since it made sense to me that it should work. However it does not. Not real sure why. Maybe you are onto something when you mentioned you were unsure if it was a structure or a query object.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

Can you dump the Results object? The test page just shows an error "Variable USERNAME is undefined"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

Oh Sorry about that.
I set the username and pass in an application.cfm in another dir. Copied it over to that dirs application.cfm. You should be able to run it now.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

It looks like it is query. Did you try a regular query loop?

<cfloop query="ContactQuery.Results">
...
</cfloop>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 01, 2009 Jan 01, 2009

Copy link to clipboard

Copied

LATEST
Nope. I am dumb and didn't really think about it. The fact that it is a query nested in a structure threw me off. The code that works was

<cfloop query="ContactQuery.Results">


<tr>
<td></td><td>#firstname#</td><td>#lastname#</td><td>#email#</td><td>#randrange(10000,99999)#</td>
</tr>

</cfloop>

Thanks for the help, sorry about that dumb question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation