Skip to main content
Known Participant
November 30, 2009
Question

cfloop and horizontal repeating rows

  • November 30, 2009
  • 2 replies
  • 670 views

So I have this xml file that I'm looping thru and I have it displaying the results in a horizontal repeating row layout. One thing I'm not sure of is how to tell it to only repeat 5 items per row before starting a new row. Right now it's just displaying everything in one long row. Here's the code I have right now.

<table width="180" border="0" cellspacing="0" cellpadding="0">

  <tr><cfloop from="1" to="#arrayLen(videos)#" index="i">

    <td align="center" valign="middle">

    <table width="180" border="0" cellpadding="0" cellspacing="0"> 

<tr> 

  <td width="5%"><a href="http://blah.org/app/sites/#videos.websiteID#.aspx/websiteID=#videos.websiteID#&videoID=#videos.videoID#"><img src="#videos.thumbnailUrl#" width="80" height="80" border="0" /></a> 

  </td> 

  </tr>

<tr>

  <td><a href="http://blah.org/app/sites/#videos.websiteID#.aspx/websiteID=#videos.websiteID#&videoID=#videos.videoID#" class="video-link">#videos.videoTitle#</a> <br />

    <span class="video-info">(#videos.videoDuration#)</span></td>

  </tr> 

</table>

    </td></cfloop>

  </tr>

</table>

This topic has been closed for replies.

2 replies

pyae phyoe shein
Known Participant
December 1, 2009

Here you go, "5" is what you want to limit.

<table width="500" height="100%" bgcolor="#ffffff" border="1">
    <tr>
    <cfloop from="1" to="10" index="i">
        <td valign="middle" align="center">
            A
        </td>
    <cfif i MOD 5 EQ 0></tr><tr></cfif>
    </cfloop>   
</table>
Inspiring
November 30, 2009

Use the mod operator.

<cfif SomeVariable mod SomeNumber is 0>do something.