Home arrow ColdFusion arrow Creating NextPrev Link in Cold Fusion
COLDFUSION

Creating NextPrev Link in Cold Fusion


Creating a Next/Prev link for query results in Cold Fusion is very easy with <cfloop> tag. Passing parameters to Start row and End row limits the record display in the specified range. Almost all of our database- driven applications require paging of query results. It might be handy if we had a custom tag or script written already. Just what we need is to extend that code wherever we want to place the paging and then change a few parameters.  In this article, I show you how we can create Cold Fusion database query results with "Next 1 2 3 4... Prev" links.

Author Info:
By: Shiju Rajan
Rating: 5 stars5 stars5 stars5 stars5 stars / 59
March 31, 2004
TABLE OF CONTENTS:
  1. · Creating NextPrev Link in Cold Fusion
  2. · Calculate the Offset and Limit Rows
  3. · Pass More Parameters to Create/Prev Link

print this article
SEARCH DEVARTICLES

Creating NextPrev Link in Cold Fusion
(Page 1 of 3 )

Using <cfquery> tag

First we need to write a select statement to pull the data from the database. Cold Fusion uses <cfquery> tag to execute database commands.  You may need to set up a data source name in the Cold Fusion administrator panel/ODBC Data sources to make a connection to the database.  If you are using a shared server, you may ask your server administrator to set up one data source name for you.

Im using a test table name called 'employee' to explain the paging example.


<!--- query for pulling employee details --->
<cfquery name="q_fetch" datasource="mydsn"
select id
namedept from employee
</cfquery>

When we run this query through a Cold Fusion page it creates a query object with some return information. The return object consists of recordCount, currentRow and  columnList variables. recordCount gives us the number of records returned by the query.

If you want to see the output of query results, use <cfdump var=# q_fetch #>. This <cfdump> tag is very useful for debugging purposes.


blog comments powered by Disqus
COLDFUSION ARTICLES

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials