Questions tagged [cfloop]

CFLoop: ColdFusion Loop This is a conditional loop. A conditional loop iterates over a set of instructions as long as a condition is True. To use this type of loop correctly, the instructions must change the condition every time the loop iterates, until the condition is False. Conditional loops are known as WHILE loops, as in, "loop WHILE this condition is true."

<cfloop> is a ColdFusion tag that is used to iterate over data. It supports five different types of loops:

  1. Index Loops
  2. Condition Loops
  3. Looping over a Query
  4. Looping over a List
  5. Looping over a Structure

Read more about the different kinds of loops here

145 questions
12
votes
3 answers

Looping over lists in cf9

Page 116 of the developer's guide says "Unlike the cfloop tag, CFScript for-in loops do not provide built-in support for looping over queries and lists." Q: How do I loop over a list using the new script syntax in ColdFusion 9?
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
9
votes
1 answer

Nested cfloops with less records than outer loop cause "array index out of range" error

I'm very curious why this is happening. I've run into it twice now, and after a ton of googling/so'ing, I haven't found any reason I actually understand. The gist of it: Query 1: selectContent (6 records; no blanks/nulls etc) Query 2: selectPricing…
sckd
  • 405
  • 3
  • 11
9
votes
4 answers

cfloop vs cfoutput on queries

I develop using ColdFusion and wanted to know what is the best strategy to loop over large query result set. Is there any performance difference between using cfloop and cfoutput? If not, is there any reason to prefer one over the other?
Abbadon
  • 2,513
  • 3
  • 25
  • 33
8
votes
5 answers

CFML - query row to structure

I would like to handle a row from a query by a function, where I pass the row as a structure. ideally... #myfunction(#row#)# I could set it up like this too...
Daniel
  • 34,125
  • 17
  • 102
  • 150
6
votes
4 answers

Looping through an array using ColdFusion

I have a shopping cart array, which has a variable to tell me if the product is an accessory or not, this will be either yes or no. I need to loop through the cart and find out the following: If the cart contains accessories only; do whatever. If…
Jason Congerton
  • 750
  • 2
  • 9
  • 23
6
votes
2 answers

ordering with cfloop

Hi I have a loop which outputs The problem is the key(which is a year) is output in the wrong order, it outputs 2009 2010 2011 As far as I can see there in no built in method for…
Ross Mark
  • 63
  • 1
  • 3
6
votes
1 answer

Avoid heap error while looping in coldfusion

I am trying to loop over a 2-D array whose dimensions are 12000 * 20 and I am continuously getting java.lang.OutOfMemoryError. Initially I thought this might be because of heap size so I increased my heap size but I was still getting the same…
Abhishekh Gupta
  • 6,206
  • 4
  • 18
  • 46
6
votes
1 answer

How to get a dynamic attribute name in cfloop over query in ColdFusion

I'm inside a cfloop over a query. I want to get an attribute, but I won't know what that attribute will be until runtime. Using #qryResult[MyAttr]# fails with the error "Complex object types cannot be converted to simple values." What is the syntax…
Kip
  • 107,154
  • 87
  • 232
  • 265
6
votes
3 answers

Evaluate function

Is there a better way to write the following? This loop is assigning every field in the query to a corresponding form field. I…
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
5
votes
3 answers

Get value of variables running in cfloop using cfthread join

Thanks for replying!! But I am still not able to do it. Error that I am getting is "Element objGet1 is undefined in a Java object of type class coldfusion.runtime.VariableScope." Below is my full code. I just want to dump the value of each thread…
Deepak Yadav
  • 1,724
  • 3
  • 23
  • 38
5
votes
1 answer

Using nested cfloop queries

I have 2 tables. One is for categories, the second is for Questions. category table: category_id category_name questions table: question_name question_id category_id How can I loop though all the category names and show the questions…
jeff
  • 313
  • 2
  • 4
  • 10
5
votes
1 answer

How to split the query column value into two line inside of anchor tag using coldfusion?

I've cfquery loop, then I've displayed the one query column value(Text) into anchor tag. For Example #testQuery.Title# Assume that testQuery.Title variable is return "Defines an…
Venkatesh
  • 75
  • 4
4
votes
1 answer

Getting value from cfquery when query column is a variable

I'm stuck... can't remember how to make this work. The code:
earachefl
  • 1,880
  • 7
  • 31
  • 55
4
votes
5 answers

How to find the nested cfoutput recordcount when using group

Consider the following:

#type#

#name#
resources.recordcount would give me the total number of records, but is there an elegant way of…
Neokoenig
  • 1,102
  • 7
  • 16
3
votes
2 answers

coldfusion query loop not cooperating

I'm trying to create a function to create csv files from queries. After I run the query, I'm looping through it and appending each row's fields to a StringBuffer object. To that end, I'm putting the column names into an array:
earachefl
  • 1,880
  • 7
  • 31
  • 55
1
2 3
9 10