ASP输出表格 分页求助
发布网友
发布时间:2022-09-16 23:52
我来回答
共1个回答
热心网友
时间:2023-10-14 09:52
<table height="50" width="800" align="center" border="1">
<tr>
<td width="400">您所在的页面是首页--<%response.Write(type1)%></td><td><a href="shouye.asp">返回到首页</a></td><td><a href="javascript:history.go(-1)">返回到上一层</a></td></tr>
</table>
<table width="800" align="center" border="1">
<tr><td width="50">编号</td><td width="600">标题</td><td>发表时间</td></tr>
<% type1=request.QueryString("type")
dim Sql
Sql="select * from shouye where type='"&type1&"' order by time desc"
rs.open Sql,conn,3,3
if Not rs.Bof and Not rs.Eof Then
dim page_size
dim page_no
dim page_total
if request("page_no")="" then
page_no=1
else
page_no=cint(request("page_no"))
end if
session("page_no")=page_no
page_size=10
rs.pagesize=page_size
page_total=rs.pagecount
rs.absolutepage=page_no
dim i , j
i=0
j=page_size
do while not rs.eof and j>0
i=i+1
j=j-1
x=(page_no-1)*page_size+i
n=x mod 2
if n=0 then
%>
<tr><td><div align="center"><%=(page_no-1)*page_size+i%></div></td><td><a href="shouyexwmb.asp?id=<%=rs("id")%>"><%=rs("title")%></a></td><td><%=rs("time")%></td></tr>
<%else%>
<tr><td><div align="center"><%=(page_no-1)*page_size+i%></div></td><td><a href="shouyexwmb.asp?id=<%=rs("id")%>"><%=rs("title")%></a></td><td><%=rs("time")%></td></tr>
<%end if%>
<% rs.MoveNext
Loop
End If
%></table>
<p align="center"> 共
<%=rs.recordcount%>
条,每页
<%=rs.pagesize%>
条,
当前<%=page_no%>/<%=rs.pagecount%>页</p>
<p align="center">
<%if page_no>1 then%>
<a href="more.asp?page_no=<%=page_no-1%>&type=<%= request.QueryString("type")%>&nickname=<%=request.QueryString("nickname") %>" >上一页</a>
<%else%>
<%end if%>
<%for k=1 to rs.pagecount%>
<%if k<>page_no then %>
<a href="more.asp?page_no=<%=k%>&type=<%= request.QueryString("type")%>&nickname=<%= request.QueryString("nickname") %>"></a>
<%else%>
<%end if%>
<%next%>
<%if page_no < rs.pagecount then%>
<a href="more.asp?page_no=<%=page_no+1%>&type=<%= request.QueryString("type")%>&nickname=<%= request.QueryString("nickname") %>" >下一页</a>
<%else%>
<%end if%>
<%if page_no<>1 then%>
<a href="more.asp?page_no=<%=1%>&type=<%= request.QueryString("type")%>&nickname=<%= request.QueryString("nickname") %>" >第一页</a>
<%else%>
<%end if%>
<%if page_no<>rs.pagecount then %>
<a href="more.asp?page_no=<%=rs.pagecount%>&type=<%= request.QueryString("type")%>&nickname=<%= request.QueryString("nickname") %>" >末页</a>
<%else%>
<%end if%>
先试一下这段分页显示代码,其中的一些链接稍作改动就可以了。我一直都用这样的分页,挺好用的。希望能帮助你