title: Coldfusion and Pagination
body: <p>First I am very new to ColdFusion, but am learning pretty quickly. So I am trying to build a large database that originally displays all results with 25 lines per page and have a next/prev link to navigate through the pages.  </p>
  
  <p>That all works fine, but when I perform a search, and when the new results display of about a couple of pages worth, the pagination links don't work.  When I click on the "next" link it goes back to the original all records display.  How can I fix this or what do I need to do to make it work? </p>
  
  <p>Sorry I'm new at posting and this is my first one.  Hope this is better.</p>
  
  <p>My pagination code...</p>
  
  <pre><code>&lt;cfset Next = StartRow + DisplayRows&gt;
  &lt;cfset Previous = StartRow - DisplayRows&gt; 
  
  &lt;cfoutput&gt; 
    &lt;cfif Previous GTE 1&gt; 
      &lt;a href="#CGI.Script_Name#?StartRow=#Previous#"&gt;&lt;b&gt;Previous #DisplayRows# Records&lt;/b&gt;&lt;/a&gt; 
    &lt;cfelse&gt; 
      Previous Records 
    &lt;/cfif&gt; 
    &lt;b&gt; | &lt;/b&gt; 
    &lt;cfif Next lte records.RecordCount&gt; 
      &lt;a href="#CGI.Script_Name#?StartRow=#Next#"&gt;&lt;b&gt;Next 
      &lt;cfif (records.RecordCount - Next) lt DisplayRows&gt; 
        #Evalute((records.RecordCount - Next)+1)# 
      &lt;cfelse&gt; 
        #DisplayRows# 
      &lt;/cfif&gt;Records&lt;/b&gt;&lt;/a&gt;
    &lt;cfelse&gt; Next Records 
    &lt;/cfif&gt; 
  &lt;cfoutput&gt;
  </code></pre>
  
  <p>My code at the top... </p>
  
  <pre><code>&lt;cfparam name="StartRow" default="1"&gt; 
  &lt;cfparam name="DisplayRows" default="25"&gt; 
  
  &lt;cfset ToRow = StartRow + (DisplayRows - 1)&gt; 
  &lt;cfif ToRow gt records.RecordCount&gt; 
    &lt;cfset ToRow = records.RecordCount&gt; 
  &lt;/cfif&gt;
  </code></pre>
  
  <p>Let me know if you need to see more...thank you.</p>