asp分页代码求助!!!
显示数据库清单的asp页面代码如下,但是数据一多了就还是一页数据,麻烦添加分页代码,不胜感激!<html><head><metahttp-equiv="Content-T...
显示数据库清单的asp页面代码如下,但是数据一多了就还是一页数据,麻烦添加分页代码,不胜感激!
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>工作日志管理系统 - 查询记录</title>
<link href="images/css.css" type="text/css" rel="stylesheet">
<script>
function check(frm){
var msg="";
if(frm.vipName.value==""){
msg="\n姓名不能为空。\n";
}else if(frm.vipName.value.length>5){
msg="\n姓名最多5个字。\n";
}
if(msg!=""){
alert(msg);
return false;
}
}
</script>
</head>
<body>
<div class="logo"><a href="index.asp"><img src="images/logo.gif" border="0"></a></div>
<div class="bodyBgHalf">
<div class="verNavi">
<!--#include file="navi.asp"-->
</div>
<div class="mainbox">
<p class="colorTitle">查询结果</p>
<%
Session("thisURL")="goodsList.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("rzdb.mdb")
set rs=server.CreateObject("adodb.recordset")
Set rs=Conn.execute("select * from goods")
if rs.eof then
response.write VBCRLF & " <strong>数据库为空。</strong>"
else
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
response.write VBCRLF & " <th height=30>编号</th>"
response.write VBCRLF & " <th>故障类型</th>"
response.write VBCRLF & " <th>已完成工作</th>"
response.write VBCRLF & " <th>未完成工作</th>"
response.write VBCRLF & " <th>姓名</th>"
response.write VBCRLF & " <th>日期</th>"
response.write VBCRLF & " <th>备注</th>"
response.write VBCRLF & " </tr>"
do while not rs.eof
response.write VBCRLF & " <tr>"
response.write VBCRLF & " <td>" & rs("ID") & " </td>"
response.write VBCRLF & " <td>" & rs("gzlx") & " </td>"
response.write VBCRLF & " <td>" & rs("ywc") & " </td>"
response.write VBCRLF & " <td>" & rs("wwc") & " </td>"
response.write VBCRLF & " <td>" & rs("rzuser") & " </td>"
response.write VBCRLF & " <td>" & rs("rq") & " </td>"
response.write VBCRLF & " <td>" & rs("bz") & " </td>"
response.write VBCRLF & " <td><a href='mdfGoods.asp?mID=" & rs("ID") & "'>修改</a> <a href='delGoods_Do.asp?dID=" & rs("ID") & "'>删除</a></td>"
response.write VBCRLF & " </tr>"
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<p> </p>
<p> </p>
</div>
</div>
</body>
</html>
是从access里的rzdb.mdb数据库取相应的数据 展开
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>工作日志管理系统 - 查询记录</title>
<link href="images/css.css" type="text/css" rel="stylesheet">
<script>
function check(frm){
var msg="";
if(frm.vipName.value==""){
msg="\n姓名不能为空。\n";
}else if(frm.vipName.value.length>5){
msg="\n姓名最多5个字。\n";
}
if(msg!=""){
alert(msg);
return false;
}
}
</script>
</head>
<body>
<div class="logo"><a href="index.asp"><img src="images/logo.gif" border="0"></a></div>
<div class="bodyBgHalf">
<div class="verNavi">
<!--#include file="navi.asp"-->
</div>
<div class="mainbox">
<p class="colorTitle">查询结果</p>
<%
Session("thisURL")="goodsList.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("rzdb.mdb")
set rs=server.CreateObject("adodb.recordset")
Set rs=Conn.execute("select * from goods")
if rs.eof then
response.write VBCRLF & " <strong>数据库为空。</strong>"
else
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
response.write VBCRLF & " <th height=30>编号</th>"
response.write VBCRLF & " <th>故障类型</th>"
response.write VBCRLF & " <th>已完成工作</th>"
response.write VBCRLF & " <th>未完成工作</th>"
response.write VBCRLF & " <th>姓名</th>"
response.write VBCRLF & " <th>日期</th>"
response.write VBCRLF & " <th>备注</th>"
response.write VBCRLF & " </tr>"
do while not rs.eof
response.write VBCRLF & " <tr>"
response.write VBCRLF & " <td>" & rs("ID") & " </td>"
response.write VBCRLF & " <td>" & rs("gzlx") & " </td>"
response.write VBCRLF & " <td>" & rs("ywc") & " </td>"
response.write VBCRLF & " <td>" & rs("wwc") & " </td>"
response.write VBCRLF & " <td>" & rs("rzuser") & " </td>"
response.write VBCRLF & " <td>" & rs("rq") & " </td>"
response.write VBCRLF & " <td>" & rs("bz") & " </td>"
response.write VBCRLF & " <td><a href='mdfGoods.asp?mID=" & rs("ID") & "'>修改</a> <a href='delGoods_Do.asp?dID=" & rs("ID") & "'>删除</a></td>"
response.write VBCRLF & " </tr>"
rs.movenext
loop
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<p> </p>
<p> </p>
</div>
</div>
</body>
</html>
是从access里的rzdb.mdb数据库取相应的数据 展开
4个回答
展开全部
我的理解回答下一楼:多次使用<% %>,HTML与ASP代码 混编会降低输出效率。。。所以我见过全站都是response.write的
给楼主的代码:改了一下,没测试,可以试试,都是我以前用的代码,不行的话Hi我吧
ADO的recordset 效率不是很高,特别是数据量大的时候
网上有文章:关于数据库离线,可以使用getRows与参数化查询
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>工作日志管理系统 - 查询记录</title>
<link href="images/css.css" type="text/css" rel="stylesheet">
<script>
function check(frm){
var msg="";
if(frm.vipName.value==""){
msg="\n姓名不能为空。\n";
}else if(frm.vipName.value.length>5){
msg="\n姓名最多5个字。\n";
}
if(msg!=""){
alert(msg);
return false;
}
}
</script>
</head>
<body>
<div class="logo"><a href="index.asp"><img src="images/logo.gif" border="0"></a></div>
<div class="bodyBgHalf">
<div class="verNavi">
<!--#include file="navi.asp"-->
</div>
<div class="mainbox">
<p class="colorTitle">查询结果</p>
<%
function Pagination(RecordCounts,PageSizes,page,link)
'RecordCounts--记录总数
'PageSizes--每页记录数
'page--当前页
'link--链接地址
page=cint(page)
RecordCounts=cint(RecordCounts)
PageSizes=cint(PageSizes)
dim i,m,n,LinkBreak,PageCounts
PageCounts=RecordCounts\PageSizes
if RecordCounts mod PageSizes>0 then
PageCounts=PageCounts+1
end if
LinkBreak=""
if page>5 and PageCounts>10 then
LinkBreak = LinkBreak & "<A title=""首页"" href="&link&"1>◄</A> <A title=""前十页"" href="&link
if page>10 then
LinkBreak = LinkBreak & page-10
else
LinkBreak = LinkBreak & 1
end if
LinkBreak = LinkBreak &">ᐊ</A> "
end if
if page<=5 or PageCounts<10 then
a=-page+1
if PageCounts>10 then
b=-page+10
else
b=-page+PageCounts
end if
elseif page>=PageCounts-5 then
a=PageCounts-page-9
b=PageCounts-page
else
a=-5
b=4
end if
for i= a to b
if i=0 then
LinkBreak=LinkBreak & "<font>" & page+i & "</font> "
else
LinkBreak=LinkBreak &"<a href="& link & page+i & ">" & page+i & "</a> "
end if
next
if PageCounts>10 and page<PageCounts-5 then
LinkBreak=LinkBreak&"<A title=""后十页"" href="&link
if page<PageCounts-10 then
LinkBreak = LinkBreak &page+10
else
LinkBreak = LinkBreak & PageCounts
end if
LinkBreak = LinkBreak &">ᐅ</A> <A title=""末页"" href="&link&PageCounts&">►</A> "
end if
Pagination="<div class=""Pagination"">一共有<font>"&RecordCounts&"</font>条记录 每页<font>"&PageSizes&"</font>条 共<font>"&PageCounts&"</font>页 ["& LinkBreak &"] </div>"
end function
Session("thisURL")="goodsList.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("rzdb.mdb")
set rs=server.CreateObject("adodb.recordset")
Set rs=Conn.execute("select * from goods")
if rs.eof then
response.write VBCRLF & " <strong>数据库为空。</strong>"
else
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
response.write VBCRLF & " <th height=30>编号</th>"
response.write VBCRLF & " <th>故障类型</th>"
response.write VBCRLF & " <th>已完成工作</th>"
response.write VBCRLF & " <th>未完成工作</th>"
response.write VBCRLF & " <th>姓名</th>"
response.write VBCRLF & " <th>日期</th>"
response.write VBCRLF & " <th>备注</th>"
response.write VBCRLF & " </tr>"
dim page:page=1
if request.QueryString("pageid")<>"" or then
dim str : str=request.QueryString("pageid")
dim tj:tj=len(str)
dim tk:tK=0
if tJ>5 then
for ti=1 to tj
tK=asc(mid(str,ti,1))
if tK>57 or tK<48 then
exit for
end if
next
if tI>tJ then
page=clng(str)
end if
end if
end if
rs.pagesize=20
rs.absolutepage=page
i=0
do while not rs.eof and i<rs.pagesize
response.write VBCRLF & " <tr>"
response.write VBCRLF & " <td>" & rs("ID") & " </td>"
response.write VBCRLF & " <td>" & rs("gzlx") & " </td>"
response.write VBCRLF & " <td>" & rs("ywc") & " </td>"
response.write VBCRLF & " <td>" & rs("wwc") & " </td>"
response.write VBCRLF & " <td>" & rs("rzuser") & " </td>"
response.write VBCRLF & " <td>" & rs("rq") & " </td>"
response.write VBCRLF & " <td>" & rs("bz") & " </td>"
response.write VBCRLF & " <td><a href='mdfGoods.asp?mID=" & rs("ID") & "'>修改</a> <a href='delGoods_Do.asp?dID=" & rs("ID") & "'>删除</a></td>"
response.write VBCRLF & " </tr>"
i=i+1
rs.movenext
loop
response.Write("</table>")
response.Write(pagination(rs.recordcount,rs.pagesize,page,"?pageid="))
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<p> </p>
<p> </p>
</div>
</div>
</body>
</html>
给楼主的代码:改了一下,没测试,可以试试,都是我以前用的代码,不行的话Hi我吧
ADO的recordset 效率不是很高,特别是数据量大的时候
网上有文章:关于数据库离线,可以使用getRows与参数化查询
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>工作日志管理系统 - 查询记录</title>
<link href="images/css.css" type="text/css" rel="stylesheet">
<script>
function check(frm){
var msg="";
if(frm.vipName.value==""){
msg="\n姓名不能为空。\n";
}else if(frm.vipName.value.length>5){
msg="\n姓名最多5个字。\n";
}
if(msg!=""){
alert(msg);
return false;
}
}
</script>
</head>
<body>
<div class="logo"><a href="index.asp"><img src="images/logo.gif" border="0"></a></div>
<div class="bodyBgHalf">
<div class="verNavi">
<!--#include file="navi.asp"-->
</div>
<div class="mainbox">
<p class="colorTitle">查询结果</p>
<%
function Pagination(RecordCounts,PageSizes,page,link)
'RecordCounts--记录总数
'PageSizes--每页记录数
'page--当前页
'link--链接地址
page=cint(page)
RecordCounts=cint(RecordCounts)
PageSizes=cint(PageSizes)
dim i,m,n,LinkBreak,PageCounts
PageCounts=RecordCounts\PageSizes
if RecordCounts mod PageSizes>0 then
PageCounts=PageCounts+1
end if
LinkBreak=""
if page>5 and PageCounts>10 then
LinkBreak = LinkBreak & "<A title=""首页"" href="&link&"1>◄</A> <A title=""前十页"" href="&link
if page>10 then
LinkBreak = LinkBreak & page-10
else
LinkBreak = LinkBreak & 1
end if
LinkBreak = LinkBreak &">ᐊ</A> "
end if
if page<=5 or PageCounts<10 then
a=-page+1
if PageCounts>10 then
b=-page+10
else
b=-page+PageCounts
end if
elseif page>=PageCounts-5 then
a=PageCounts-page-9
b=PageCounts-page
else
a=-5
b=4
end if
for i= a to b
if i=0 then
LinkBreak=LinkBreak & "<font>" & page+i & "</font> "
else
LinkBreak=LinkBreak &"<a href="& link & page+i & ">" & page+i & "</a> "
end if
next
if PageCounts>10 and page<PageCounts-5 then
LinkBreak=LinkBreak&"<A title=""后十页"" href="&link
if page<PageCounts-10 then
LinkBreak = LinkBreak &page+10
else
LinkBreak = LinkBreak & PageCounts
end if
LinkBreak = LinkBreak &">ᐅ</A> <A title=""末页"" href="&link&PageCounts&">►</A> "
end if
Pagination="<div class=""Pagination"">一共有<font>"&RecordCounts&"</font>条记录 每页<font>"&PageSizes&"</font>条 共<font>"&PageCounts&"</font>页 ["& LinkBreak &"] </div>"
end function
Session("thisURL")="goodsList.asp"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("rzdb.mdb")
set rs=server.CreateObject("adodb.recordset")
Set rs=Conn.execute("select * from goods")
if rs.eof then
response.write VBCRLF & " <strong>数据库为空。</strong>"
else
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
response.write VBCRLF & " <th height=30>编号</th>"
response.write VBCRLF & " <th>故障类型</th>"
response.write VBCRLF & " <th>已完成工作</th>"
response.write VBCRLF & " <th>未完成工作</th>"
response.write VBCRLF & " <th>姓名</th>"
response.write VBCRLF & " <th>日期</th>"
response.write VBCRLF & " <th>备注</th>"
response.write VBCRLF & " </tr>"
dim page:page=1
if request.QueryString("pageid")<>"" or then
dim str : str=request.QueryString("pageid")
dim tj:tj=len(str)
dim tk:tK=0
if tJ>5 then
for ti=1 to tj
tK=asc(mid(str,ti,1))
if tK>57 or tK<48 then
exit for
end if
next
if tI>tJ then
page=clng(str)
end if
end if
end if
rs.pagesize=20
rs.absolutepage=page
i=0
do while not rs.eof and i<rs.pagesize
response.write VBCRLF & " <tr>"
response.write VBCRLF & " <td>" & rs("ID") & " </td>"
response.write VBCRLF & " <td>" & rs("gzlx") & " </td>"
response.write VBCRLF & " <td>" & rs("ywc") & " </td>"
response.write VBCRLF & " <td>" & rs("wwc") & " </td>"
response.write VBCRLF & " <td>" & rs("rzuser") & " </td>"
response.write VBCRLF & " <td>" & rs("rq") & " </td>"
response.write VBCRLF & " <td>" & rs("bz") & " </td>"
response.write VBCRLF & " <td><a href='mdfGoods.asp?mID=" & rs("ID") & "'>修改</a> <a href='delGoods_Do.asp?dID=" & rs("ID") & "'>删除</a></td>"
response.write VBCRLF & " </tr>"
i=i+1
rs.movenext
loop
response.Write("</table>")
response.Write(pagination(rs.recordcount,rs.pagesize,page,"?pageid="))
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
<p> </p>
<p> </p>
</div>
</div>
</body>
</html>
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
展开全部
不理解 你的代码为啥要这样写
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
不感觉很麻烦吗?
有个简单的分页代码:
rs.pagesize=3
paged=request("paged")
if ((paged="") or (not(IsNumeric(paged)))) then paged=1
paged=CLng(paged)
if paged<1 then paged=1
if paged>rs.pagecount then paged=rs.pagecount
rs.absolutepage=paged
for ipage=1 to rs.pagesize
这里是你用显示的内容
<form action="?typeid=<%=typeid%>&ntypeid=<%=ntypeid%>&bigclassname=<%=request("bigclassname")%>&classname=<%=request("classname")%>">本类信息共:<%=rs.recordcount%>条 当前页:<%=paged%>/<%=rs.pagecount%> 页
<%
if(rs.pagecount>1 and paged<>1) then
response.write("<a href='?paged=1&typeid="&typeid&"&ntypeid="&ntypeid&"' title='首页' >首页</a> <a href='?paged="&paged-1&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='上一页' >上一页</a> ")
else
response.Write("首页 上一页 ")
end if
if(rs.pagecount>1 and paged<>rs.pagecount) then
response.write("<a href='?paged="&paged+1&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='下一页' >下一页</a> <a href='?paged="&rs.pagecount&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='尾页' >尾页</a> ")
else
response.Write("下一页 尾页 ")
end if
%>
转到:
<select name="paged" onchange="form.submit();">
<%
for i=1 to rs.pagecount
%>
<option value="<%=i%>" <%if i=paged then response.write("selected") %>>第 <%=i%> 页</option>
<% next %>
</select>
</form>
response.write VBCRLF & " <table border=1 align=center cellspacing=0 cellpadding=2>"
response.write VBCRLF & " <tr align=center>"
不感觉很麻烦吗?
有个简单的分页代码:
rs.pagesize=3
paged=request("paged")
if ((paged="") or (not(IsNumeric(paged)))) then paged=1
paged=CLng(paged)
if paged<1 then paged=1
if paged>rs.pagecount then paged=rs.pagecount
rs.absolutepage=paged
for ipage=1 to rs.pagesize
这里是你用显示的内容
<form action="?typeid=<%=typeid%>&ntypeid=<%=ntypeid%>&bigclassname=<%=request("bigclassname")%>&classname=<%=request("classname")%>">本类信息共:<%=rs.recordcount%>条 当前页:<%=paged%>/<%=rs.pagecount%> 页
<%
if(rs.pagecount>1 and paged<>1) then
response.write("<a href='?paged=1&typeid="&typeid&"&ntypeid="&ntypeid&"' title='首页' >首页</a> <a href='?paged="&paged-1&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='上一页' >上一页</a> ")
else
response.Write("首页 上一页 ")
end if
if(rs.pagecount>1 and paged<>rs.pagecount) then
response.write("<a href='?paged="&paged+1&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='下一页' >下一页</a> <a href='?paged="&rs.pagecount&"&typeid="&typeid&"&ntypeid="&ntypeid&"' title='尾页' >尾页</a> ")
else
response.Write("下一页 尾页 ")
end if
%>
转到:
<select name="paged" onchange="form.submit();">
<%
for i=1 to rs.pagecount
%>
<option value="<%=i%>" <%if i=paged then response.write("selected") %>>第 <%=i%> 页</option>
<% next %>
</select>
</form>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
有个成熟的分页类XDownPage,网上查一下可以找到
1、包含数据库连接代码
<!--#include file="inc/conn.asp"-->
2、包含分页类代码
<!--#include file="inc/XDownPage.asp"-->
<%
sql = "这里写你的sql代码"
dim mypage
Set mypage=new xdownpage
mypage.getconn=conn
mypage.getsql=sql
mypage.pagesize = 30
set rs=mypage.getrs()
for i=1 to mypage.pagesize
if rs.eof then
exit for
else
'这里写要输出的内容
rs.movenext
end if
next%>
mypage.showpage()'分页导航栏
set mypage=nothing
详细说明可以Q我,25533895
1、包含数据库连接代码
<!--#include file="inc/conn.asp"-->
2、包含分页类代码
<!--#include file="inc/XDownPage.asp"-->
<%
sql = "这里写你的sql代码"
dim mypage
Set mypage=new xdownpage
mypage.getconn=conn
mypage.getsql=sql
mypage.pagesize = 30
set rs=mypage.getrs()
for i=1 to mypage.pagesize
if rs.eof then
exit for
else
'这里写要输出的内容
rs.movenext
end if
next%>
mypage.showpage()'分页导航栏
set mypage=nothing
详细说明可以Q我,25533895
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<table width="700" border="0" cellspacing="0" cellpadding="0">
<%
page=request("page")
if page="" then page=1
if not(isnumeric(page)) then page=1
if page<1 then page=1
page=int(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from xwzx"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
else
rs.pagesize=8
totalpage=rs.pagecount
if page>totalpage then page=totalpage
totalrec=rs.recordcount
rs.absolutepage=page
i=0
c=0
do while not rs.eof and (i<rs.pagesize)
i=i+1
c=c+1
%>
<tr>
<td width="31" height="30" align="center"><img src="images/gsjj_03.jpg" width="10" height="10" /></td>
<td width="588" align="left" class="iz"> <a href="news.asp?id=<%=rs("id")%>" class="z"><%=rs("bt")%></a> </td>
<td width="81" class="iz">[ <%=year(rs("date"))%>/<%=month(rs("date"))%>/<%=day(rs("date"))%> ]</td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="70" align="left" valign="bottom"><center>
<table border="0" cellpadding="0" cellspacing="1" class="iz">
<tr>
<td height="34" align="center" valign="middle"><span class="xz"><font color="#000000" class="xz">共 <font color="#000000"><%=totalpage%></font> 页 当前是:第 <font color="#000000"><%=page%></font> 页<font color="#000000">
<%if page-1>0 then%>
<a href="xwzx.asp?page=<%=page-1%>"><font color="#000000">上一页</font></a>
<%else%>
<font color="#FF0000">上一页</font>
<%end if%>
<%if page+1<=totalpage then%>
<a href="xwzx.asp?page=<%=page+1%>"><font color="#000000">下一页</font></a>
<%else%>
<font color="#FF0000">下一页</font>
<%end if%>
</font></font>
<select name="select" onChange="location=this.options[this.selectedIndex].value">
<%for i=1 to totalpage%>
<option value="xwzx.asp?page=<%=i%>" <%if page=i then response.write "selected"%>><%=i%></option>
<%next%>
</select>
</span></td>
</tr>
</table>
</center>
这个代码是我的网站一个新闻的一个代码~!绝对好使~表名是XWZX 你需要更改~!
<%
page=request("page")
if page="" then page=1
if not(isnumeric(page)) then page=1
if page<1 then page=1
page=int(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from xwzx"
rs.open sql,conn,1,3
if rs.bof and rs.eof then
else
rs.pagesize=8
totalpage=rs.pagecount
if page>totalpage then page=totalpage
totalrec=rs.recordcount
rs.absolutepage=page
i=0
c=0
do while not rs.eof and (i<rs.pagesize)
i=i+1
c=c+1
%>
<tr>
<td width="31" height="30" align="center"><img src="images/gsjj_03.jpg" width="10" height="10" /></td>
<td width="588" align="left" class="iz"> <a href="news.asp?id=<%=rs("id")%>" class="z"><%=rs("bt")%></a> </td>
<td width="81" class="iz">[ <%=year(rs("date"))%>/<%=month(rs("date"))%>/<%=day(rs("date"))%> ]</td>
</tr>
<%
rs.movenext
loop
end if
%>
</table>
<table width="700" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="70" align="left" valign="bottom"><center>
<table border="0" cellpadding="0" cellspacing="1" class="iz">
<tr>
<td height="34" align="center" valign="middle"><span class="xz"><font color="#000000" class="xz">共 <font color="#000000"><%=totalpage%></font> 页 当前是:第 <font color="#000000"><%=page%></font> 页<font color="#000000">
<%if page-1>0 then%>
<a href="xwzx.asp?page=<%=page-1%>"><font color="#000000">上一页</font></a>
<%else%>
<font color="#FF0000">上一页</font>
<%end if%>
<%if page+1<=totalpage then%>
<a href="xwzx.asp?page=<%=page+1%>"><font color="#000000">下一页</font></a>
<%else%>
<font color="#FF0000">下一页</font>
<%end if%>
</font></font>
<select name="select" onChange="location=this.options[this.selectedIndex].value">
<%for i=1 to totalpage%>
<option value="xwzx.asp?page=<%=i%>" <%if page=i then response.write "selected"%>><%=i%></option>
<%next%>
</select>
</span></td>
</tr>
</table>
</center>
这个代码是我的网站一个新闻的一个代码~!绝对好使~表名是XWZX 你需要更改~!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询