paging | show Code title:paging (modifiable)
Description:add paging to your the record retrieval. But, do it with the good ' ol form field that allows
To just type in directly what page ya Wanna go. This are our fave! It even alternates the background
Color (bgcolor) of each row, to make viewing the recordset even easier ... We use different tweaked versions
Of this one all on our site! Example of this code snippet in our International page.
We have made it so this it'll display a hyperlinked the one in one column, then a truncated
Description using the Left () function in the next column. The hyperlink would take you to the specific
Article or record, (whatever you ' re using it for).
We use a JavaScript valid number checker on this one and just to make sure the person doesn ' t enter any weird
Characters into the page Number field of the form. We don ' t normally do this, but if ya want the
JavaScript for number checking, check out our jsnumbervalidator.
Copy and paste this snippet As-is into your editor:
<%
Const adUseClient = 3
Const adOpenStatic = 3
specific = Request.QueryString ("specific")
If specific = "" Then
Set rs = Server.CreateObject ("ADODB.") RecordSet ")
Rs. CursorLocation = adUseClient
Rs. CacheSize = 5
MyPage = Request.Form ("Pgnum")
If mypage = "" Then mypage = 1
Rs. Open "SELECT * from TABLE ORDER by FIELD ASC", Cndz, adOpenStatic
If not Rs. EOF Then
Rs. MoveFirst
Rs. PageSize = ' Change this number to exactly how many records per page ya wanna show
Maxcount = CInt (rs. PageCount)
Rs. AbsolutePage = MyPage
Howmanyrecs = 0
Response.Write "<table border=0>"
LinkCount = 0
While not Rs. EOF and Howmanyrecs < rs.pagesize
If linkcount Mod 2 = 0 Then bgcolor = "bgcolor= #F0F0F0" Else bgcolor = ""
Response.Write "<tr" &bgColor& "><td nowrap>" &_
"<a href=" "Mypage.asp?specific=" &rs ("ID") & "" > "&rs (" FIELD ") &" </a></td> "&_
"<td width=" "100%" "Nowrap>" &left (RS ("FIELD2"), & "</td></tr>"
LinkCount = LinkCount + 1
Rs. MoveNext
Howmanyrecs = howmanyrecs + 1
Wend
Response.Write "</table>"
If maxcount > 1 Then
If MyPage + 1 > Maxcount Then nextpg = 1 Else nextpg = mypage + 1
Response.Write "<form method=post action=" "MyPage.asp" ">" &_
"<nobr>page" &mypage& "of" &maxcount& "Navigate to Page:<input
Type=text size=3 maxlength=3 value= "" &nextPg& "" "> <input type=submit name=gopgnum
Value=go></nobr></form> "
End If
Else Response.Write "Sorry, the Nothing are available at the moment."
End If
Rs. Close
Set rs = Nothing
Else
Set rs = Cndz.execute ("select * from TABLE WHERE ID =" &specific& ")
Do Until Rs. Eof
Response.Write "" &rs ("FIELD") & "<br>" &_
"" &rs ("FIELD2") & "<br>"
Rs. MoveNext
Loop
Rs. Close
Set rs = Nothing
End If
%>