How to display Navigation buttons in Coldfusion

 I have items in the table and am displaying 4 items per row. But it displays all items (or records) from the items table.
 How can I add [First][Prev] ....  [Next] [Last] buttons so that each page only displays three rows of items?
 I have also seen [1][2][3] ...[Last] also.
 Both methods will work whichever is simpler.


 Here is the current code:

      <cfoutput query="GetFeaturedItems">
      <td align="center" >
               <TD align="center" bgcolor="white">
                   <tr><td>Title: #Title#</td></tr>
                  <tr><td>Item No:#ItemNo#</td></tr>
        <cfif GetFeaturedItems.currentRow mod 4 eq 0>
            <cfif GetFeaturedItems.currentRow gt 1>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongSoftware Team Lead, ex-Business Systems Analyst , ex-Senior Application EngineerCommented:
so the trick could be to get the "previous record Unique ID" and the "Next record Unique ID" in your SQL statement. so that when you populate the data into HTML, we can where we are navigate to...

for example. you can read this article:

ColdFusion and Pagination

ColdFusion and Pagination – Six Years Later

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gurpreet Singh RandhawaCEOCommented:
create a custom tag like this:


<CFPARAM Name="CurrentPage" Default="1">	<!---	Default the page listing to 1	--->

<!---	Get all products for product listing	--->
	SELECT * FROM Products

<!---	CF_PageThru will help us break up the product listing into pages.
	The ADDEDPATH parameter is used to pass the search parameter CLASS
	through the links of the generated page-through navigation.
<CF_PAGETHRU TOTALRECORDS="#GetItems.RecordCount#" CURRENTPAGE="#CurrentPage#"

Open in new window

attached files for pagination, just remove the .txt extension from the end of the cfm file.
sgleeAuthor Commented:
That worked fine. Thank you.

I downloaded and renamed pagethru.txt to pagethru.cfm.
Then I placed pagethru.cfm in the same folder where I have pagination.cfm that has the code in ID: 41019483.
When I run pagination.cfm, I get an error: "Variable CLASS is undefined."
Obviously I did not handle pagethru.cfm correctly.
Gurpreet Singh RandhawaCEOCommented:
yes, class is not a mandatory field, you can remove it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.