Skip to main content
Known Participant
August 15, 2007
Question

order by down columns

  • August 15, 2007
  • 2 replies
  • 354 views
Hi i am displaying a cfoutput query in 3 columns using

<cfif #CurrentRow# MOD 3 is 3><TR></cfif>

<cfif #CurrentRow# MOD 3 is 0></TR></cfif>

the output is ordered by name, how do i get the order to read down each column rather than accross each row, ie

instead of having

adam, adao, adar

adam,
adao,
adar,
This topic has been closed for replies.

2 replies

Inspiring
August 16, 2007
The above answer is wrong. A better approach is to create a 2D array with 3 columns. Do some math to determine how many records go into each column and populate the array. Then output the array in your html table.
Inspiring
August 16, 2007
If you're only outputting one column then I would go with the first approach

Inspiring
August 15, 2007
Something like this:
records = query.recordcount;
rows = ceiling(records / 3);
col1 = 1;
col2 = 2;
col3 = 3;
</cfscript>
<table>
<cfoutput>
<cfloop from = "1" to ="#rows#" index = "ii">
<td>#query.fieldname[col1]#</td>
<cfif col2 lte records>
<td>#query.fieldname[col2]#</td>
</cfif>
<cfif col3 lte records>
<td>#query.fieldname[col3]#</td>
</cfif>
</tr>
add 3 to each col1,2, and 3
</cfloop>