Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making "items 1 to 10 of 52" message from query

Status
Not open for further replies.

leadman

Programmer
Jun 11, 2001
177
US
Hi all
I have a search results page that splits up the resutling records returned over several pages (i have it set to 10 resutls per page). I want to have a message at the top of each page stating "now viewing X to Y of Z items" where x is the first record on the page and Y is the last and Z is the recordcount. Im not sure how to get the Y though. I have a varible available to each new page called "firstrecord" that increments by 10 with each click of the "next 10" button. This is what im using for X. How can I determine Y so that it will accurately tell when someone is viewing say "items 51 to 52 of 52"?
Thanks
 
Try using this script:


<!--- Set the default startrow to 1 if a value was not passed. --->
<!--- Determine whether or not to show the previous or next links. --->
<cfparam name=&quot;startRow&quot; default=&quot;1&quot;>
<!--- Set the value of endrow to the maxrows + startrow - 1 --->
<cfset endRow = startRow + onEachPage - 1>
<!--- If the end row is greater than the recordcount, determine how many records are left. --->
<cfif endRow GTE queryRecordCount>
<cfset endRow = queryRecordCount>
<cfset next = false>
<!--- Otherwaise, set Next to true and determine the next set of records. --->
<cfelse>
<cfset next = true>
<cfif endRow + onEachPage GT queryRecordCount>
<cfset nextNum = queryRecordCount - endRow>
<cfelse>
<cfset nextNum = onEachPage>
</cfif>
<cfset nextStart = endRow + 1>
</cfif>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top