Working example.

 

<cfset data = listToArray('1,2,3,4,5,6,7,8,9,10,11,12,13') />

<cfset cols = 3 />

<cfset rows = ceiling(arrayLen(data) / cols) />

 

<cfoutput>

      <table>

      <cfloop index="i" from="1" to="#rows#">

            <tr>

                  <cfif i lte arrayLen(data)><td>#data[i]#</td></cfif>

                  <cfif i+rows*1 lte
arrayLen(data)><td>#data[i+rows*1]#</td></cfif>

                  <cfif i+rows*2 lte
arrayLen(data)><td>#data[i+rows*2]#</td></cfif>

            </tr>

      </cfloop>

      </table>

</cfoutput>

 

Regards

Dale Fraser

 

http://dale.fraser.id.au/blog

 

  _____  

From: cfaussie@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf
Of Taco Fleur
Sent: Thursday, 5 April 2007 3:22 PM
To: cfaussie@googlegroups.com
Subject: [cfaussie] Re: outputting recordset

 

Hi Seona,

 

that is it! Thanks.

 

 * count
 * count + divisor
 * count + (divisor * 2) 

 

On 4/5/07, Seona Bellamy <[EMAIL PROTECTED]> wrote: 

On 05/04/07, Dale Fraser < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> >
wrote: 

So are you saying a fixed number of rows 6

Or a fixed number of columns 3?


I believe the line in the original email was: 
 

 

I need to output a recordset in a table, infinite rows, and maximum 3
columns in width.


I'm more interested in knowing if there was a reason for the number of empty
cells in the third column. Because I'm pretty sure that the columns could
have been closer to even in length, and that would be easier to do I think.
The maths is making better sense in my head, anyway. Then again, knowing my
history with maths, I'm not sure that's saying much... 

Basically, what I'm thinking is something along these lines:

* Divide your number of records by 3 and round it off to an integer (I'll
call this divisor). This is the number of records you will have in each of
the first two (complete) columns. The third column may or may not have this
many records. 

* Loop over your recordset this many times, with a counter of some sort to
count the iterations.

* In the loop, get the three cells as follows:
  * count
  * count + divisor
  * count + (divisor * 2) 

I haven't tested this, so it's purely theoretical and may or may not work.
Oh, and you'd probably want to test if the value exists in the third column
because that one may not be full.


Cheers, 

Seona. 



Web Design, Web development, Graphic Design and Complete Internet Solutions
an industry leader with commercial IT experience since 1994 . 





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to