Solved

Nesting cfloop queries

Posted on 2014-03-17
3
257 Views
Last Modified: 2014-03-18
Hello.

I need to do the following:

I have  MyTable structured like this.

ID      NumImages
a          3
b          6
c          4

I want to output each ID as many times as there is NumImages.recordcount ,output it as a1,a2,a3  then output the next ID NumImages.recordcount as b1,b2,b3...



Trying to achieve this result:

a1
a2
a3

b1
b2
b3
b4
b5
b6

c1
c2
c3
c4

I have tried all kings of nesting cfoutputs, cfloops, cfoutput loops..I just don't get it.
Hope this makes sense.
Can you help?
0
Comment
Question by:izweig
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 39936140
Do a regular query loop, then within it loop from=1 to=#NumImages#

<cfoutput query="yourQuery">
      <cfloop from="1" to="#NumImages#" index="counter">
           #yourQuery.id##counter#<br/>
      </cfloop>
      <!--- extra break between id's --->
      <br/>
</cfoutput>
0
 

Author Closing Comment

by:izweig
ID: 39936751
Awesome thanks.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39936847
Welcome.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question