PDA

View Full Version : complicated paging problem


BarrMan
12-10-2005, 04:55 PM
I got a paging code that checks if the current page greater than 3 if it isn't it shows the page links from 1 to 5(there is another condition there), if it is greater than 3 it shows the current page - 2 to currentpage + 2.
Here is the code:
<%
If CurrentPage < 3 Then
If PageCount <= 5 Then
For i = 1 To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = 1 To 5
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
End If
Else
If PageCount >= (CurrentPage + 2) Then
For i = (CurrentPage - 2) To (CurrentPage + 2)
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&?page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = (PageCount - 5) To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
End If
End If
%>
The problem is:
Everytime i press on the 4th page it gets me to the first page although in the querystring it shows page=4.
To see the full page you can click here: http://e.domaindlx.com/BarrMan/BestForums/forums.asp?s=1&page=1&w=thread&f=allforums&o=both

vinyl-junkie
12-10-2005, 06:51 PM
Everytime i press on the 4th page it gets me to the first page although in the querystring it shows page=4.
Your paging logic looks fine. Are you sure there isn't some logic problem within the page that is using that query string? If I were you, I would put a Response.Write and Response.End statement pair in that page at a strategic place just to see what's getting passed and what the page might be doing with it. Move that around as necessary, but often times, that's the quickest way to narrow down what's going on.

BarrMan
12-10-2005, 07:51 PM
<%
If CurrentPage < 3 Then
If PageCount <= 5 Then
For i = 1 To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = 1 To 5
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
End If
Else
If PageCount >= (CurrentPage + 2) Then
For i = (CurrentPage - 2) To (CurrentPage + 2)
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
<!---------------------------!> Response.Write "<a href=forums.asp?s=1&?page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
Else
For i = (PageCount - 5) To PageCount
If i = CurrentPage Then
Response.Write i & VBCrlf
Else
Response.Write "<a href=forums.asp?s=1&page=" & i & "&w=" & word & "&f=" & forum & "&o=" & foption & ">" & i & "</a>" & VBcrlf
End If
Next
End If
End If
%>