sqlmysqlpaginationasp-classic

ASP/SQL/Paging - Get current page number


I answered my own question, sorry!

I started with this:

If Request("currentPage") <> "" AND isNumeric(Request("currentPage")) Then
    currentPage = Request("currentPage")
Else
    currentPage = 1
End If

And then on my paging links, I added:

.asp?currentPage="&currentPage+1&"

///////////////////////////////////////////////////////////////////

I have upgraded my search script to use LIMIT paging.

I am simply trying to work out what the current page is, based on the 'offset' value but I'm having some amateur troubles.

This is what I have:

currentPage = pageRange / rpp

' page range is the offset value for the LIMIT clause, for example 0, 20, 40...
' rpp is results per page value, for example 20...

If cInt(currentPage) <= 0 Then
    currentPage = 1
End If

But page 1 and 2 both show "page 1", page 3 shows "page 2", page 4 shows "page 3" and so on. Obviously there is something wrong with this calculation but I cannot see it.

Any ideas?


Solution

  • May be better to keep track on page num and evaluate offset from it, than tracking offset? Or at least evaluate currentPage as cInt(pageRange / rpp)+1