3 Replies Latest reply on Dec 2, 2006 1:39 AM by Hugh Neale

    bit of a tricky one ....

    Hugh Neale Level 1
      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
        • 1. Re: bit of a tricky one ....
          Hugh Neale Level 1
          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>
          • 2. Re: bit of a tricky one ....
            Dan Bracuk Level 5
            <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>
            • 3. Re: bit of a tricky one ....
              Hugh Neale Level 1
              OMG - Thanks so much!