[thelist] Cold Fusion -- looping records in 3 columns
.jeff
jeff at members.evolt.org
Sat Mar 1 05:27:01 CST 2003
gravyface (?!),
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: GravyFace
>
> without having to write 3 separate queries, is there
> anyway to continue looping the output of a query to
> three <td>'s (columns)? 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.
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
depending on the order you want the data output, this can either be easy or
difficult. you have two options:
left-to-right/top-to-bottom (easy)
-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------
| 7 | 8 | 9 |
-------------
<table>
<tr>
<cfoutput query="myquery">
<td>#currentrow#</td>
<cfif currentrow NEQ recordcount AND NOT currentrow MOD 3>
</tr>
<tr>
</cfif>
</cfoutput>
</tr>
</table>
word of advice with this version though, the code above doesn't account for
times when the total number of records returned is not divisible by 3.
top-to-bottom/left-to-right (hard)
-------------
| 1 | 4 | 7 |
-------------
| 2 | 5 | 8 |
-------------
| 3 | 6 | 9 |
-------------
easier to show than to try to copy/paste the code here and explain
http://www.jeffhowden.com/code/coldfusion/paged_column_output.cfm
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> Is there anyway to set a record limit condition in
> the loop?
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
sure, take a look at startrow/endrow attributes if you're using the <cfloop>
tags or startrow/maxrows attributes if you're using the <cfoutput> tags.
good luck,
.jeff
http://evolt.org/
jeff at members.evolt.org
http://members.evolt.org/jeff/
More information about the thelist
mailing list