• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

order by down columns

New Here ,
Aug 15, 2007 Aug 15, 2007

Copy link to clipboard

Copied

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,
TOPICS
Advanced techniques

Views

317

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 15, 2007 Aug 15, 2007

Copy link to clipboard

Copied

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 16, 2007 Aug 16, 2007

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 16, 2007 Aug 16, 2007

Copy link to clipboard

Copied

LATEST
If you're only outputting one column then I would go with the first approach

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation