k=20
pageno=request("pageno")
if pageno="" then
pageno=1
else
pageno=cint(pageno)
end if
set rs= Server.CreateObject("adodb.recordset")
rsstr="select * from news"
rs.open rsstr,conn,1,1
pages=int(rs.recordcount/k)+1
rs_recordcount=rs.recordcount
rs.close
ps=pageno*k
response.write rs_recordcount
if pageno=1 then
rsstr="select top "&k&" * from news order by id"
else
rsstr="select top "&k&" * from news where id not in (select top "&(pageno-1)*k&" id from news order by id) order by id"
end if
rs.open rsstr,conn,1,1
response.write "<ul>"
i=1
do while not rs.eof and not rs.bof
response.write "<li>"
response.write rs("id")&" "&rs("title")
response.write "</li>"
rs.movenext
i=i+1
loop
response.write "</ul>"
num=pageno-4
num1=pageno+5
if num<=0 then num=1
if num>(pages-4) then num=(pages-4)
if num1<10 then num1=10
if num1>pages then num1=pages
response.write "<p>"
response.write "<div class='pages'>"
response.write "<a href='?pageno=1'>第一页</a> "
for i=num to num1
if pageno=i then
response.write "<span class='red'>"&i&"</span> "
else
response.write "<a href='?pageno="&i&"'>"&i&"</a> "
end if
next
response.write "<a href='?pageno="&pages&"'>尾页</a> "
response.write "</div>"