asp分页,下面的ASP代码能够读取读取数据库的内容,现请高手帮忙写个分页,每岩显示20条
<!--#includefile="conn.asp"--><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metaht...
<!--#include file="conn.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>签约楼盘</title>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #999999;
}
-->
</style>
</head>
<%
Set db1=Server.CreateObject("ADODB.Connection")
connstr1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("tuangou/tuangou.mdb")
db1.open connstr1
set rs=server.CreateObject("adodb.recordset")
sql="select top 100 * from baoming order by id desc"
rs.open sql,db1,1,1
%>
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><!--#include file="top3.asp"--></td>
</tr>
<tr>
<td width="150" height="400" align="center" valign="top" bgcolor="#FAEDD1"><!--#include file="left4.asp"--></td><td valign="top"><table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25"><span class="f12hei">您现在的位置: > 签约楼盘</span></td>
</tr>
<tr>
<td><hr size="1"/></td>
</tr>
<tr>
<td height="380" align="center" valign="top" class="xukuang"><table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" bgcolor="#CCCCCC"><div align="center">小区名称</div></td>
<td width="44%" bgcolor="#CCCCCC"><div align="center">所选套餐</div></td>
<td width="34%" bgcolor="#CCCCCC"><div align="center">在线报名</div></td>
</tr>
</table>
<table width="96%" border="0" cellpadding="0" cellspacing="0" class="f12hei">
<%for i=1 to 100%>
<tr>
<td width="22%" height="18" align="center"><%=rs("xiaoqu")%></td>
<td width="44%" align="center"><font color="#FF0000"><%=rs("email")%></font></td>
<td width="34%" align="center"><a href="zxyd.asp?sjs=<%=rs("xiaoqu")%>" class="black12" target="_blank">在线报名 >></a></td>
</tr>
<tr>
<td height="1" colspan="3" align="center" bgcolor="#E7E7E7"></td>
</tr>
<%
rs.movenext
next
rs.close
set rs=nothing
db1.close
set db1=nothing
%>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><!--#include file="down2.asp" --></td>
</tr>
</table>
</body>
</html>
有哪位高手帮帮忙。把我上边的代码和分页代码加在一起。我直接复制粘贴就直接用了。谢谢。我在加分。。。 展开
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>签约楼盘</title>
<link href="css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #999999;
}
-->
</style>
</head>
<%
Set db1=Server.CreateObject("ADODB.Connection")
connstr1="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("tuangou/tuangou.mdb")
db1.open connstr1
set rs=server.CreateObject("adodb.recordset")
sql="select top 100 * from baoming order by id desc"
rs.open sql,db1,1,1
%>
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><!--#include file="top3.asp"--></td>
</tr>
<tr>
<td width="150" height="400" align="center" valign="top" bgcolor="#FAEDD1"><!--#include file="left4.asp"--></td><td valign="top"><table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="25"><span class="f12hei">您现在的位置: > 签约楼盘</span></td>
</tr>
<tr>
<td><hr size="1"/></td>
</tr>
<tr>
<td height="380" align="center" valign="top" class="xukuang"><table width="96%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" bgcolor="#CCCCCC"><div align="center">小区名称</div></td>
<td width="44%" bgcolor="#CCCCCC"><div align="center">所选套餐</div></td>
<td width="34%" bgcolor="#CCCCCC"><div align="center">在线报名</div></td>
</tr>
</table>
<table width="96%" border="0" cellpadding="0" cellspacing="0" class="f12hei">
<%for i=1 to 100%>
<tr>
<td width="22%" height="18" align="center"><%=rs("xiaoqu")%></td>
<td width="44%" align="center"><font color="#FF0000"><%=rs("email")%></font></td>
<td width="34%" align="center"><a href="zxyd.asp?sjs=<%=rs("xiaoqu")%>" class="black12" target="_blank">在线报名 >></a></td>
</tr>
<tr>
<td height="1" colspan="3" align="center" bgcolor="#E7E7E7"></td>
</tr>
<%
rs.movenext
next
rs.close
set rs=nothing
db1.close
set db1=nothing
%>
</table></td>
</tr>
<tr>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><!--#include file="down2.asp" --></td>
</tr>
</table>
</body>
</html>
有哪位高手帮帮忙。把我上边的代码和分页代码加在一起。我直接复制粘贴就直接用了。谢谢。我在加分。。。 展开
3个回答
展开全部
<%
'...
rs.open sql,db1,1,1
rs.pagesize=20 '设置每页显示的记录数
num=rs.recordcount '记录总数
pagenum=rs.pagecount '页总数
page=request("page") '获取页码
If page <> "" then
page = cint(page)
if err.number <> 0 then
err.clear
page = 1
end if
if page < 1 then
page = 1
end if
else
page = 1
End if
if page*rs.pagesize > num and not((page-1)*rs.pagesize < num)then
page=1
end if
rs.absolutepage = page
if page<>pagenum then
lablenum=rs.pagesize
else
lablenum=num-(page-1)*rs.pagesize
end if
for i=1 to lablenum
%>
<!--循环显示-->
<%
rs.movenext
next
rs.close
'...
%>
'...
rs.open sql,db1,1,1
rs.pagesize=20 '设置每页显示的记录数
num=rs.recordcount '记录总数
pagenum=rs.pagecount '页总数
page=request("page") '获取页码
If page <> "" then
page = cint(page)
if err.number <> 0 then
err.clear
page = 1
end if
if page < 1 then
page = 1
end if
else
page = 1
End if
if page*rs.pagesize > num and not((page-1)*rs.pagesize < num)then
page=1
end if
rs.absolutepage = page
if page<>pagenum then
lablenum=rs.pagesize
else
lablenum=num-(page-1)*rs.pagesize
end if
for i=1 to lablenum
%>
<!--循环显示-->
<%
rs.movenext
next
rs.close
'...
%>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
佳达源
2024-10-28 广告
2024-10-28 广告
AR0144CSSM20SUKA0-CPBR这款产品,作为我司产品线中的重要一员,集成了高精度的传感器技术与先进的图像处理算法,广泛应用于安防监控、工业自动化及机器视觉等领域。其卓越的性能与稳定性,确保了在各种复杂环境下的精准数据采集与高效...
点击进入详情页
本回答由佳达源提供
展开全部
<%mykey=""
Const PAGESIZEs=20
Const PARTSIZE=10
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from Hyd_Food order by Food_id desc "
rs.open sql,conn,1,1
recordcounts = rs.RecordCount
RS.PageSize = PAGESIZEs
pagecounts = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecounts then
page = pagecounts
end if
If rs.Eof And rs.Bof Then
Response.Write("<tr><td colspan=6> <font color='red'><br><br>没有任何产品!<br><br></font></td></tr>")
Else
if recordcounts > 0 then RS.AbsolutePage = page
for i = 1 to PAGESIZEs
if RS.EOF then exit for
%>
<tr onmouseover="this.style.backgroundColor='#FF99FF';this.style.cursor='hand';" onmouseout="this.style.backgroundColor='';" title="产品名称:<%=rs("food_name")%> " >
<td width="42" height="25" align="center"><%=rs("food_id")%></td>
<td width="120" height="25" align="center"><a href="<%=dir%>/Product/Product_Show.asp?Id=<%=Rs("food_id")%>" target='_blank'><%=hyd.LeftT(rs("food_name"),20)%></a></td>
<td width="101" align="center">
<%=conn.execute ("select title from hyd_food_type where id="&rs("food_bigid")&"")(0)%></td>
<td width="68" align="center"><%=rs("food_shopname")%></td>
<td width="81" height="25" align="center"><%=rs("food_price")%> 元/<%=rs("food_ptype")%></td>
<td width="100" height="25" align="center"><%=rs("food_zl")%> 折</td>
<td width="42" align="center"><%if rs("food_tj")=1 then response.Write "已推荐" else response.Write "未推荐" %></td>
<td width="50" align="center"><%if rs("food_show")=1 then response.Write "显示" else response.Write "不显示" %></td>
<td width="57" height="25" align="center"><%if rs("food_sh")=1 then response.Write "审核" else response.Write "未审核" %></td>
<td width="44" height="25" align="center"><a href="Food_edit.asp?id=<%=rs("food_id")%>">编辑</a></td>
<td width="45" height="25" align="center"><input name="doid" type="checkbox" id="doid" value="<%=rs("food_Id")%>" /></td>
</tr>
<% RS.MoveNext()
next
End If
%>
<%
if pagecounts > 0 then
response.write("<table width=""95%"" style=""margin-top:30px;"" align=center cellspacing=3 cellpadding=3><tr><td align=center>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecounts & "</b> 每页<b>" & pagesizes & "</b>条 共<b>" & recordcounts & "</b>条 分页:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecounts then Epage = pagecounts
if page > 1 then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=1"">首页</a>]")
if page > PARTSIZE then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecounts then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Epage + 1 & """>[>>]</a>")
end if
if Epage <> pagecounts then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & pagecounts & """>尾页</a>]")
response.write("</td></tr></table>")
end if
rs.close
%>
Const PAGESIZEs=20
Const PARTSIZE=10
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from Hyd_Food order by Food_id desc "
rs.open sql,conn,1,1
recordcounts = rs.RecordCount
RS.PageSize = PAGESIZEs
pagecounts = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecounts then
page = pagecounts
end if
If rs.Eof And rs.Bof Then
Response.Write("<tr><td colspan=6> <font color='red'><br><br>没有任何产品!<br><br></font></td></tr>")
Else
if recordcounts > 0 then RS.AbsolutePage = page
for i = 1 to PAGESIZEs
if RS.EOF then exit for
%>
<tr onmouseover="this.style.backgroundColor='#FF99FF';this.style.cursor='hand';" onmouseout="this.style.backgroundColor='';" title="产品名称:<%=rs("food_name")%> " >
<td width="42" height="25" align="center"><%=rs("food_id")%></td>
<td width="120" height="25" align="center"><a href="<%=dir%>/Product/Product_Show.asp?Id=<%=Rs("food_id")%>" target='_blank'><%=hyd.LeftT(rs("food_name"),20)%></a></td>
<td width="101" align="center">
<%=conn.execute ("select title from hyd_food_type where id="&rs("food_bigid")&"")(0)%></td>
<td width="68" align="center"><%=rs("food_shopname")%></td>
<td width="81" height="25" align="center"><%=rs("food_price")%> 元/<%=rs("food_ptype")%></td>
<td width="100" height="25" align="center"><%=rs("food_zl")%> 折</td>
<td width="42" align="center"><%if rs("food_tj")=1 then response.Write "已推荐" else response.Write "未推荐" %></td>
<td width="50" align="center"><%if rs("food_show")=1 then response.Write "显示" else response.Write "不显示" %></td>
<td width="57" height="25" align="center"><%if rs("food_sh")=1 then response.Write "审核" else response.Write "未审核" %></td>
<td width="44" height="25" align="center"><a href="Food_edit.asp?id=<%=rs("food_id")%>">编辑</a></td>
<td width="45" height="25" align="center"><input name="doid" type="checkbox" id="doid" value="<%=rs("food_Id")%>" /></td>
</tr>
<% RS.MoveNext()
next
End If
%>
<%
if pagecounts > 0 then
response.write("<table width=""95%"" style=""margin-top:30px;"" align=center cellspacing=3 cellpadding=3><tr><td align=center>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecounts & "</b> 每页<b>" & pagesizes & "</b>条 共<b>" & recordcounts & "</b>条 分页:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecounts then Epage = pagecounts
if page > 1 then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=1"">首页</a>]")
if page > PARTSIZE then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecounts then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Epage + 1 & """>[>>]</a>")
end if
if Epage <> pagecounts then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & pagecounts & """>尾页</a>]")
response.write("</td></tr></table>")
end if
rs.close
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
rs.pagesize=N 设置每页为N条记录
rs.pagecount 根据 pagesize 的设置返回总页数
代码参考楼上
rs.pagecount 根据 pagesize 的设置返回总页数
代码参考楼上
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询