Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:26:56+00:00 2026-06-05T16:26:56+00:00

I have implemented pagination to my data, but the problem is I only have

  • 0

I have implemented pagination to my data, but the problem is I only have the Next and Previous links, like so:

enter image description here

What I would like to do is add page numbers, with the page number I am on as normal text, and the other pages as links. So if I am on page 3 of 5, it would like look like this:

enter image description here

Here is what I have so far:

<cfset data = queryNew("id,name,age,active","integer,varchar,integer,bit")>

<cfloop index="x" from="1" to="50">
<cfset queryAddRow(data)>
<cfset querySetCell(data,"id",x)>
<cfset querySetCell(data,"name","User #x#")>
<cfset querySetCell(data,"age",randRange(20,90))>
<cfset querySetCell(data,"active",false)>
</cfloop>

<cfset perpage = 10>

<cfparam name="url.start" default="1">
<cfif not isNumeric(url.start) or url.start lt 1 or url.start gt data.recordCount or round(url.start) neq url.start>
<cfset url.start = 1>
</cfif>

<h2>Random People</h2>

<cfoutput query="data" startrow="#url.start#" maxrows="#perpage#">
#currentrow#) #name#<br />
</cfoutput>

<p align="right">
[
<cfif url.start gt 1>
<cfset link = cgi.script_name & "?start=" & (url.start - perpage)>
<cfoutput><a href="#link#">Previous Page</a></cfoutput>
<cfelse>
Previous Page
</cfif>
/
<cfif (url.start + perpage - 1) lt data.recordCount>
<cfset link = cgi.script_name & "?start=" & (url.start + perpage)>
<cfoutput><a href="#link#">Next Page</a></cfoutput>
<cfelse>
Next Page
</cfif>
]
</p>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:26:57+00:00Added an answer on June 5, 2026 at 4:26 pm

    This was a fun question. How about this to build your list of page links:

    <cfset pageList = "">
    <cfloop from="1" to="#ceiling(data.RecordCount/perpage)#" index="i">
        <!--- Determine the start record for selected page --->
        <cfset targetRecord = 1 + (perpage * (i - 1))>
        <cfif ceiling(url.start/perpage) NEQ i>
            <cfset link = cgi.script_name & "?start=" & targetRecord>
            <cfset pageList = listAppend(pageList, "<a href=""#link#"">#i#</a>", " ")>
        <cfelse>
            <cfset pageList = listAppend(pageList, i, " ")>
        </cfif>
    </cfloop>
    

    Now you can just drop pageList into your navigation section like so:

    <p align="right">
    [
    <cfif url.start gt 1>
        <cfset link = cgi.script_name & "?start=" & (url.start - perpage)>
        <cfoutput><a href="#link#">Previous Page</a></cfoutput>
    <cfelse>
        Previous Page
    </cfif>
    /
    #pageList#
    /
    <cfif (url.start + perpage - 1) lt data.recordCount>
        <cfset link = cgi.script_name & "?start=" & (url.start + perpage)>
        <cfoutput><a href="#link#">Next Page</a></cfoutput>
    <cfelse>
        Next Page
    </cfif>
    ]
    </p>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement pagination in my Servlet/EJB/JPA-Hibernate project, but I can't figure
I have just implemented custom pagination by overriding the -(BOOL)knowsPageRange: and -(NSRect)rectForPage: methods. These
I have already implemented some AJAX pagination in my Rails app by using the
I have implemented Twitter4J in my Android application and it's works fine. But after
I have implemented a jquery ui autocomplete with data from database. Right now what
i've followed the pagination tutorial from http://framework.zend.com/manual/en/zend.paginator.usage.html I have successfully implemented pagination for my
I have a page /discussion and I want to implement pagination in it. Now,
I have implemented the jquery thick box in my page to show another page
How do i implement pagination in salesforce. I have a VF page which uses
I have implemented the UIScrollView with pagination, according to the PhotoScroller example. However, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.