ASP分页显示

ASP分页显示,第1张

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>

<!--#include file="conn.asp" -->

<%

sql="select * from bizhi order by id desc"

set rs=server.CreateObject("adodb.recordset")

rs.open sql,conn,1,3,1

%>

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>无标题文档</title>

</head>

<body>

<%

if rs.eof then

response.Write "暂无图片"

else

rs.pagesize=2'定义每页几张图片

zongye=rs.pagecount'计算总共几页

mrs=rs.Recordcount'计算共有几张图片

page=int(request("page"))'传递的页次

if page<=0 then page=1

if request("page")="" then page=1

rs.absolutepage=page

%>

<%

for i=1 to rs.pagesize

response.write("图片:"&rs("tupian"))

response.write("类别:"&rs("leibie"))

response.write("尺寸:"&rs("chicun"))

response.write("大小:"&rs("daxiao"))

response.write("时间:"&rs("time"))

response.write("<hr>")

rs.movenext

if rs.eof then exit for

next

%>

<p align="center">

页次:<%=page%>/<%=zongye%>

每页:<%=rs.pagesize%>共:<%=mrs%>

<% if page=1 and page=zongye then %>

首页|上一页|下一页|末页

<% elseif page=1 and not page=zongye then %>

首页|上一页|

<a href="fenye.asp?page=<%=page+1%>">下一页</a>|

<a href="fenye.asp?page=<%=zongye%>">末页</a>

<% elseif page<>1 and not page=zongye then %>

<a href="fenye.asp?page=1">首页</a>|

<a href="fenye.asp?page=<%=page-1%>">上一页</a>|

<a href="fenye.asp?page=<%=page+1%>">下一页</a>|

<a href="fenye.asp?page=<%=zongye%>">末页</a>

<% elseif page=zongye then%>

<a href="fenye.asp?page=1">首页</a>|

<a href="fenye.asp?page=<%=page-1%>">上一页</a>|

下一页|末页

<%end if%>

<%for i=1 to zongye%>

<% if i <>page then %>

<a href="fenye.asp?page=<%=i%>"><%=i%></a>

<%else%>

<%=i%>

<%end if%>

<%next

end if

rs.close

conn.close

set rs=nothing

set conn=nothing%>

</p>

</body>

</html>

'楼主可以建立索引,查询速度就会提高

<% Response.Buffer=False %>

<%

Dim connstr

connstr="Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &Server.MapPath("mychanpin.mdb")

set bb = server.CreateObject("ADODB.Connection")

bb.Open connstr

%>

<html>

<head>

<title>每日销售情况</title>

</head>

<body>

<%

set rs = server.CreateObject ("adodb.recordset")

rs.open "select * from changpin order by data desc",bb,1,1 '注意这裏是按日期查询

if request("page")="" then

page=1

else

page=cint(request("page"))

end if

rs.pagesize=12

if page=0 then page=1

if page>rs.pagecount then page=rs.pagecount

rs.absolutepage=page

%>

<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">

<tr>

<td><div align="center">序号</div></td>

<td><div align="center">日期</div></td>

<td><div align="center">已售</div></td>

</tr><%

for i=1 to rs.pagesize%>'分页代码用这个循环

<tr>

<td><div align="center"><%=rs("ID")%></div></td>

<td><div align="center"><%=rs("data")%></div></td>

<td><div align="center"><%=rs("yishou")%></div></td>

</tr><%

rs.movenext

if rs.eof then exit for

next

%>

<tr>

<td colspan=3 height=25>

<!--分页代码开始-->

<%

if page=1 then

response.write"首页  "

end if

if page<>1 then

response.write"<a href=?page=1>[首页]</a>  "

response.write"<a href=?page="&(page-1)&">[上一页]</a>  "

end if

if page<>rs.pagecount then

response.write"<a href=?page="&(page+1)&">[下一页]</a>  "

response.write"<a href=?page="&rs.pagecount&">[尾页]</a>  "

end if

if page=rs.pagecount then

response.write"尾页  "

end if

<!--分页代码结束-->

%>

</td>

</tr>

</table>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/10644993.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-10
下一篇 2023-05-10

发表评论

登录后才能评论

评论列表(0条)

保存