欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

code title: paging (modifiable)

description: add paging to your record retrieval. but, do it with the goodol 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 youre using it for).

we use a javascript valid number checker on this one, just to make sure the person doesnt enter any weird

characters into the page number field of the form. we dont 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

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 分页显示的例子(显示记录背景色替换变化)
分享到: 更多 (0)