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

bit of a tricky one ....

Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

Ok, from my query I have this:

1,2,3,4,5,6,7,8,9

And I want to turn it into this

<table>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td></td>
</tr>
</table>

now if my list now grows to this "1,2,3,4,5,6,7,8,9,10,11,12,13,14" I want my table to include a second row etc. How the **** do I program this. I am having such a tough time and its reallly strating to frustrate.

If anyone can tell me how to do this. I would be over the moon.

Many Thanks hugh
TOPICS
Advanced techniques

Views

330

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

correct answers 1 Correct answer

LEGEND , Dec 01, 2006 Dec 01, 2006
<cfset ctr = 1>
<table>
<tr>
<cfoutput>
<cfloop list="#yourlist#" index = "ThisItem">
<td>#ThisItem#</td>
<cfif ctr is ListLen(yourlist)>
</tr>
<cfelseif ctr mod 5 is 0>
</tr><tr>
</cfif>
<cfset ctr = ctr + 1>
</cfloop>
</cfoutput>
</table>

Votes

Translate

Translate
Guest
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

oh yes I have this code already.

<cfset Columns = 5>
<cfset CurrentColumn = 0>
<cfset RowCompleted = 0>

<cfset Rows=Int(usersview.RecordCount/Columns)>
<cfset OddColumns = usersview.RecordCount mod Columns>

<cfif OddColumns neq 0>
<cfset Rows = Rows +1>
</cfif>

<cfset Increment = Int(usersview.RecordCount/Columns)+1>

<table border="1">
<cfprocessingdirective suppresswhitespace="yes">


<cfloop from="1" to="#rows#" index="Row">
<cfset LeftOverIncrement = 0>
<tr>
<cfloop index="Column" from="1" to="#Columns#">
<cfif Column gt (OddColumns +1)>
<cfset LeftOverIncrement = LeftOverIncrement +1>
</cfif>
<cfset CurrentRow = (Row + (Increment * CurrentColumn) - LeftOverIncrement)>
<cfif CurrentColumn eq (Columns -1)>
<cfset CurrentColumn = 0>
<cfelse>
<cfset CurrentColumn = (CurrentColumn+1)>
</cfif>
<cfoutput>
<td><cfif (Row lt Increment or OddColumns gt 0) and (CurrentRow lte usersview.RecordCount)>#the value[CurrentRow]#<cfelse></cfif></td>
</cfoutput>
<cfif Row eq Increment>
<cfset RowCompleted = RowCompleted +1>
</cfif>
<cfif RowCompleted is OddColumns>
<cfset OddColumns =0>
</cfif>
</cfloop>
</tr>
</cfloop>
</cfprocessingdirective>
</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
LEGEND ,
Dec 01, 2006 Dec 01, 2006

Copy link to clipboard

Copied

<cfset ctr = 1>
<table>
<tr>
<cfoutput>
<cfloop list="#yourlist#" index = "ThisItem">
<td>#ThisItem#</td>
<cfif ctr is ListLen(yourlist)>
</tr>
<cfelseif ctr mod 5 is 0>
</tr><tr>
</cfif>
<cfset ctr = ctr + 1>
</cfloop>
</cfoutput>
</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
Guest
Dec 02, 2006 Dec 02, 2006

Copy link to clipboard

Copied

LATEST
OMG - Thanks so much!

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