[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
   add 1 to record counter
if cell counter = 3
   close row
   set cell counter to 0
   add 1 to cell counter

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
it out for yourself

it's really not that hard


More information about the thelist mailing list