We help IT Professionals succeed at work.
Get Started

(gdemaria) I need to do pagination to my list

lulu50 asked
Last Modified: 2014-03-13

I have a list of parent Issues and child Issues that I need to be able to display just 10 records on a time and do the pagination

<cfquery name = "QSearchResult"  datasource='#strDSN#' username='#strUID#' password='#strPWD#'>
  SELECT case when ParentIssueID is null then IssueId
              else ParentIssueID
		 end  as TopIssueID
		 , IssueID
		 , ParentIssueID
		 , TicketNumberTxt
		 , TitleOfIssue
		 , Status
		 , DateCreated
   FROM LogEntry
  order by 1 desc, case when parentIssueID is null then 1 else 2 end

<cfparam name="url.page" default="1">
<cfset page_links_shown = 5>
<cfset records_per_page = 10>

<cfset start_record = url.page * records_per_page - records_per_page>
<cfset total_pages = ceiling(QSearchResult.count/ records_per_page)>

<cfoutput query="QSearchResult">
 <cfif val(QSearchResult.ParentIssueID)> 
   <td style="padding-left:20px;">

<cfif url.page EQ 1>
   Prev Page
   <a href="index.cfm?page=#url.page-1#">Prev Page</a>

<cfif url.page * records_per_page LT QSearchResult.counts>
   <a href="pages.cfm?page=#url.page+1#">Next Page</a>
   Next Page

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE