title: ColdFusion cfloop skip row or change loop endRow
body: <p>I am trying to display 2 images, and skip one if it matches the following criteria (<code>&lt;cfif myDir.name eq property_mainimage&gt;</code> which works fine, and then continue onto the next image and display the next image until I have a total of 2 images. But when the criteria image is say in row 5, the loop displays 3 images, when the criteria image is say row 1, it displays 2 images.</p>
  
  <p>There doesn't seem to be a skip row in cfloop?</p>
  
  <p>I have tried <code>&lt;cfif counter gt 3 &gt; &lt;cfabort&gt;</code> which works but it displays the 3 images still of the criteria image is in a row greater than 3. Below is what i'm working with...</p>
  
  <pre><code>&lt;cfdirectory directory="C:\Domains\domain.com\wwwroot\uploads\images\#property_ID#\" filter="*.jpg" name="myDir" type="file" sort="datelastmodified"&gt;
  &lt;ul&gt;
    &lt;cfset counter = 0&gt;
    &lt;cfset endrowvalue = 3 &gt;
    &lt;cfloop query="myDir" endRow="#endrowvalue#"&gt;
      &lt;cfset counter = counter +1 &gt;
      &lt;li&gt;
      &lt;cfif right(myDir.name,4) is ".jpg"&gt;
        &lt;cfif fileexists("C:\Domains\ domain.com\wwwroot\uploads\ images\#property_ID#\#left(mydir.name,len(myDir.name)-4)#.jpg")&gt;
          &lt;cfif myDir.name eq property_mainimage&gt;
            DO NOT SHOW THIS IMAGE
          &lt;cfelse&gt;
            &lt;cfset endrowvalue = 1 &gt;
            &lt;cfset myDir.endRow = 1 &gt;
            test #endrowvalue#
            test #counter# &lt;img src="#request.root#uploads/images/#property_ID#/#myDir.name#" border="0" width="230px" style="margin-bottom:15px;"  /&gt;
          &lt;/cfif&gt;
        &lt;/cfif&gt;
      &lt;/cfif&gt; 
      &lt;/li&gt;
    &lt;/cfloop&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>any help would be most appreciated.</p>