asp 翻页代码

2024-11-30 16:59:48
推荐回答(1个)
回答1:

<%
Dim page
t=0
Set rs = Server.CreateObject("ADODB.RecordSet")
sql="SELECT * from NEWS order by id desc"
rs.Open sql,conn2,1,1
if not Rs.eof Then
rs.PageSize=20 '设定每页显示多少条记录 PageSize : 每页的记录数
page=trim(request("page")) '获取要显示哪一页
if not isnumeric(page) then page=1
page = Cdbl(page)
if page > rs.PageCount then
page=rs.PageCount
elseif page < 1 then
page=1
end if
rs.AbsolutePage=page '定位当前的页位置
t=(page-1) * rs.PageSize
Dim i
for i=1 to rs.PageSize
if rs.eof then
exit for
end if
t=t+1
%><贺伍%= t %> " target="_blank">告模<%=left(rs("title"),30)%> <%=rs("infotime")%>


<%
rs.movenext
next
'显示页数
dim ls_ScriptName
ls_ScriptName = request.servervariables("Script_Name")
%>
第<%=page%>页 / 共<%=rs.PageCount%>页
<%if page > 1 then%>上一页<%else%>上一页<%end if%>
|
<%
dim i
for i = 1 to rs.PageCount
%> <%=i%> <%
next
%>
|
<%if page < rs.PageCount then%>下一页<%else%>下一页<%end if%>
<%
else
response.write "尚无收录袜拍缓"
end if
rs.close
set rs = nothing
%>