分页显示的例子(显示记录背景色替换变化)

marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="0">

Code Title: Paging (modifiable)
Description: Add paging to your record retrieval. But, do it with the good'ol form field that allows you
to just type in directly what page ya wanna go to. This one is 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 over our site! See an example of this code snippet on our International page.

We have made it so that it will display a hyperlinked first item in one column, then a truncated
description using the Left() function in the next column. The hyperlink will take you to the specific
article or record, (whatever you're using it for).

marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="0">

We use a javascript valid number checker on this one, 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 = 20 '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"),40)&"</td></tr>"
LinkCount = LinkCount + 1
rs.MoveNext

marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd468_60.html" frameborder="0" width="468" scrolling="no" height="60" leftmargin="0" topmargin="0">
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 name=pgNum size=3 maxlength=3 value="""&nextPg&"""> <input type=submit name=gopgNum
value=GO></nobr></form>"
End If
Else Response.Write"Sorry, nothing is 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
%>


marginwidth="0" marginheight="0" src="http://www.aiwo1314.com/googleAdsense/gd336_280.html" frameborder="0" width="336" scrolling="no" height="280" leftmargin="0" topmargin="0">
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值