dim pagenum
dim topnum
dim totalrec
pagenum=request.querystring("page")
if pagenum="" then pagenum=1
if not IsNumeric(pagenum) then pagenum=1
if pagenum=<0 then pagenum=1
if pagenum>99999 then pagenum=1
pagenum=fix(pagenum)
topnum=pagenum*20
sql="select top "&topnum&" ID,date,title from article where type="&ID
rs.open sql,arconn,1,1
totalrec=rs.recordcount
if (totalrec mod 20)=0 then
lastpage=totalrec\20
else
lastpage=totalrec\20+1
end if
if (pagenum-1)*20>=totalrec then
if (totalrec mod 20)=0 then
pagenum=totalrec\20
else
pagenum=totalrec\20+1
end if
end if
if not pagenum=1 and (pagenum-1)*20<totalrec then
rs.move (pagenum-1)*20
else
pagenum=1
end if
而想知道点什么,可以这样做!如点[10],其HTML代码为:
<a href="page.asp?page=10">[10]</a>,而实际实现时用for循环得到!
如:
<%
for n=1 to 10
response.write "<a href='page.asp?page="&n&"'>["&n&"]</a>"
next
%>
<%
const intpagesize=20
if Request("page")="" then
intcur=1
else
select case request("page")
case "first"
intcur=1
case "previous"
intcur=cint(request("curpage"))
intcur=intcur-1
case "next"
intcur=cint(request("curpage"))
intcur=intcur+1
case "last"
intcur=cint(request("lastpage"))
case else
intcur=request("page")
end select
end if
set rst=server.createobject("ADODB.recordset")
rst.CursorLocation=2
rst.CursorType=3
rst.CacheSize=intpagesize
straccess="select * from law where answer is not null and not answer like ''"
rst.open straccess,strconn
rst.PageSize=intpagesize
if Not rst.EOF then
rst.AbsolutePage=intcur
end if
inttotal=rst.pagecount
session("inttotal")=inttotal
rscount=rst.recordcount
%>
<html>