• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Previous week / Next Week

New Here ,
Nov 05, 2012 Nov 05, 2012

Copy link to clipboard

Copied

How can i implement Previous week / Next Week, like previous n / next n records?

Can you please send me links for implmentation code or help me implement?.

Please help.

thank you.

Previous / Next n Records

http://tutorial20.easycfm.com/index.cfm?fuseaction=tutorial&tutorialID=20http://tutorial20.easycfm.com/

Views

621

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

Your easycfm link seems a good start.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 06, 2012 Nov 06, 2012

Copy link to clipboard

Copied

It really depends on your RDBMS as well, since mySQL supports functions that easily allow for you to capture just the data you want, while MSSQL requires you to just about pull back the whole recordset and then selectively retrieve a subset (the size of the pagination) from it.

For example, MSSQL 2012 finally introduced the standards-compliant FETCH and OFFSET keywords, so you could do something like

SELECT

field1,

field2,

field3

FROM table

WHERE

this=that

ORDER BY primaryKey

OFFSET 5 ROWS

FETCH NEXT 5 ROW ONLY

Since ordering by primaryKey (assume 1, 2, 3, 4, etc)  This would return the record starting at 6 and give you 5 records worth (to ID 10).

That way CF can just send the RDBMS system the offset (what page you're on) and the fetch size (the amount of records per page).  Then it's just a case of math to determine the text of "Next X records", etc.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 07, 2012 Nov 07, 2012

Copy link to clipboard

Copied

LATEST

This is how i make the Next and previous link.

== At the top of the page ==

<cfparam name="URL.StartRow" default="1">

<cfset NextRow = URL.StartRow + 25 />

<cfset PreviousRow = URL.StartRow - 25 />

<cfif PreviousRow LTE 0>

  <cfset PreviousRow = 1 />

</cfif>

== Next and previous links ==

<cfif NextRow LTE QueryName.RecordCount >

  <a href="#CGI.SCRIPT_NAME#?StartRow=#NextRow#">Next page</a>

<cfelse>

   

</cfif>

<cfif PreviousRow LT URL.StartRow>

  <a href="#CGI.SCRIPT_NAME#?StartRow=#PreviousRow#">Previous</a>

<cfelse>

   

</cfif>

== Query results ==

<cfoutput query="QueryName" startrow="#URL.StartRow#" maxrows="25">

#Your output goes here#

</cfouput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation