[thelist] Cold Fusion -- looping records in 3 columns

rudy r937 at interlog.com
Fri Feb 28 20:56:00 CST 2003


> Lets says there are 9 records returned by the query but I want to output 3
> records in the first <td>, 3 in the second, and the last 3 in the third.

there are several ways to approach this

> Is there anyway to set a record limit condition in the loop?

i would just start the table, start the row, and then use a plain cfoutput,
with the following inside it

set cell counter to 0
start the cell
set record counter to 0
print record
if record counter = 3
   close cell
   set record counter to 0
else
   add 1 to record counter
endif
if cell counter = 3
   close row
   set cell counter to 0
else
   add 1 to cell counter
endif

there's probably a couple of holes in the above code, i am sure of it

but you get the basic idea

there's one real "gotcha" in this type of logic, and i have not handled
it --

how do you know when you've done the last record?  because at that point,
you have to close the cell, and then the row, and then the table

you could borrow someone's code, but you'll feel so much better if you
figure
it out for yourself

it's really not that hard


rudy







More information about the thelist mailing list