求朋友帮忙给下面代码分页咯;最好能详细点;加上注释;谢谢啦!
<%dimconnstrconnstr="Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&Server.MapPath("xi...
<%
dim connstr
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("xinxi.mdb")
set conn=Server.CreateObject("AdoDb.Connection")
conn.Open connstr
set rs=server.CreateObject("adodb.recordset")
Sql="select * from biaoge Order by id Desc"
rs.Open Sql,Conn,1,1
%>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="560" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#1941A5">
<tr>
<td height="35" colspan="5" bgcolor="#D5D5D5"><div align="center">网络导航</div></td>
</tr>
<tr>
<td height="30" colspan="5"><a href="tianjia.asp" class="STYLE3">添加新记录</a></td>
</tr>
<% do while not rs.eof %>
<tr onMouseOver="this.bgColor='#FFFFCC' "onmouseout="this.bgColor='#ffffff'">
<td width="19%" height="28"><span class="STYLE2"><%=rs("name")%></span></td>
<td width="29%"><a href="http://<%=rs("url")%>" target="new" class="STYLE2"><%=rs("url")%></a></td>
<td width="29%"><span class="STYLE1"><%=rs("body")%></span></td>
<td width="12%"><div align="center" class="STYLE1"><a href="delete.asp?id=<%=rs("id")%>& action=del" onclick="return confirm('您确定要删除此营业点信息吗?')">删除</a></div></td>
<td width="11%"><div align="center" class="STYLE1"><a href="xiugai.asp?id=<%=rs("id")%>">修改</a></div></td>
</tr>
<%
rs.movenext
loop
%>
</table>
</form>
<%
rs.close
set rs=Nothing
conn.close
set conn=Nothing
%>
</body> 展开
dim connstr
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("xinxi.mdb")
set conn=Server.CreateObject("AdoDb.Connection")
conn.Open connstr
set rs=server.CreateObject("adodb.recordset")
Sql="select * from biaoge Order by id Desc"
rs.Open Sql,Conn,1,1
%>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="560" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#1941A5">
<tr>
<td height="35" colspan="5" bgcolor="#D5D5D5"><div align="center">网络导航</div></td>
</tr>
<tr>
<td height="30" colspan="5"><a href="tianjia.asp" class="STYLE3">添加新记录</a></td>
</tr>
<% do while not rs.eof %>
<tr onMouseOver="this.bgColor='#FFFFCC' "onmouseout="this.bgColor='#ffffff'">
<td width="19%" height="28"><span class="STYLE2"><%=rs("name")%></span></td>
<td width="29%"><a href="http://<%=rs("url")%>" target="new" class="STYLE2"><%=rs("url")%></a></td>
<td width="29%"><span class="STYLE1"><%=rs("body")%></span></td>
<td width="12%"><div align="center" class="STYLE1"><a href="delete.asp?id=<%=rs("id")%>& action=del" onclick="return confirm('您确定要删除此营业点信息吗?')">删除</a></div></td>
<td width="11%"><div align="center" class="STYLE1"><a href="xiugai.asp?id=<%=rs("id")%>">修改</a></div></td>
</tr>
<%
rs.movenext
loop
%>
</table>
</form>
<%
rs.close
set rs=Nothing
conn.close
set conn=Nothing
%>
</body> 展开
2个回答
展开全部
已经帮你的代码加了分页了
<%
'PID 页面中的其它传参连接
'page 要显示的页码
'Vcount 总记录数
'Pnum 每页记录数
'className 超连接样式
public function ThePage(Pid,page,Vcount,Pnum,className)
dim show
page = int(page)
Pcount = abs(int(-abs(Vcount/Pnum)))
if page = "" or page <= 0 then page = 1
if page>Pcount then page=Pcount
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9
If EndPageNum>Pcount then EndPageNum=Pcount
show = show&"<tr><td colspan='10' bgcolor='' align='right' style='padding-right:25px;padding-top:5px;' class='"&className&"'>"
show = show&"共<b>"&Pcount&"</b>页 共有<b>"&Vcount&"</b>记录 第<b>"&page&"</b>页 跳到第 [ "
if StartPageNum>1 then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&StartPageNum-1&"' title='前十页'><font face='webdings'>7</font></a>"
end if
For go=StartPageNum to EndPageNum
if go<>page then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&go&"'>"&go&"</a>"
else
show = show&"<b>"&go&"</b>"
end if
show = show&" "
Next
if EndPageNum<Pcount then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&EndPageNum+1&"' title='下十页'><font face='webdings'>8</font></a>"
end if
show = show& "] 页"
if page<>1 then
show = show&"<a class='"&className&"' href='?"&Pid&"page=1'> 首页</a> <a class='"&className&"' href='?"&Pid&"page="&page-1&"'>上一页</a>"
end if
if Pcount-page <> 0 then
show = show& "<a class='"&className&"' href='?"&Pid&"page="&page+1&"'> 下一页</a> <a class='"&className&"' href='?"&Pid&"page="&Pcount&"'>尾页</a>"
end if
show=show&"</tr></td>"
ThePage = show
end function
%>
<%
dim connstr
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("xinxi.mdb")
set conn=Server.CreateObject("AdoDb.Connection")
conn.Open connstr
%>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="560" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#1941A5">
<tr>
<td height="35" colspan="5" bgcolor="#D5D5D5"><div align="center">网络导航</div></td>
</tr>
<tr>
<td height="30" colspan="5"><a href="tianjia.asp" class="STYLE3">添加新记录</a></td>
</tr>
<%
set rs = server.createobject("adodb.recordset")
Sql="select * from biaoge Order by id Desc"
'分页参数设置
page = request.querystring("page")
if page = "" then page = 1
page = int(page)
Pnum = 20
className = "lwf"
PID = ""
'以下不变
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
Vcount = RS.recordcount
if RS.recordcount <> 0 then
RS.absoluteposition=RS.absoluteposition+((abs(page)-1)*Pnum)
end if
'********************************
i = 1
while not RS.eof and i<=Pnum
%>
<tr onMouseOver="this.bgColor='#FFFFCC' "onmouseout="this.bgColor='#ffffff'">
<td width="19%" height="28"><span class="STYLE2"><%=rs("name")%></span></td>
<td width="29%"><a href="http://<%=rs("url")%>" target="new" class="STYLE2"><%=rs("url")%></a></td>
<td width="29%"><span class="STYLE1"><%=rs("body")%></span></td>
<td width="12%"><div align="center" class="STYLE1"><a href="delete.asp?id=<%=rs("id")%>& action=del" onclick="return confirm('您确定要删除此营业点信息吗?')">删除</a></div></td>
<td width="11%"><div align="center" class="STYLE1"><a href="xiugai.asp?id=<%=rs("id")%>">修改</a></div></td>
</tr>
<%
rs.movenext
i = i + 1
wend
rs.close
set rs = nothing
%>
<tr>
<td width="19%" height="28" colspan="5"> <%=ThePage(Pid,page,Vcount,Pnum,className)%></td>
</tr>
</table>
</form>
<%
conn.close
set conn=Nothing
%>
</body>
<%
'PID 页面中的其它传参连接
'page 要显示的页码
'Vcount 总记录数
'Pnum 每页记录数
'className 超连接样式
public function ThePage(Pid,page,Vcount,Pnum,className)
dim show
page = int(page)
Pcount = abs(int(-abs(Vcount/Pnum)))
if page = "" or page <= 0 then page = 1
if page>Pcount then page=Pcount
StartPageNum=1
do while StartPageNum+10<=page
StartPageNum=StartPageNum+10
Loop
EndPageNum=StartPageNum+9
If EndPageNum>Pcount then EndPageNum=Pcount
show = show&"<tr><td colspan='10' bgcolor='' align='right' style='padding-right:25px;padding-top:5px;' class='"&className&"'>"
show = show&"共<b>"&Pcount&"</b>页 共有<b>"&Vcount&"</b>记录 第<b>"&page&"</b>页 跳到第 [ "
if StartPageNum>1 then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&StartPageNum-1&"' title='前十页'><font face='webdings'>7</font></a>"
end if
For go=StartPageNum to EndPageNum
if go<>page then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&go&"'>"&go&"</a>"
else
show = show&"<b>"&go&"</b>"
end if
show = show&" "
Next
if EndPageNum<Pcount then
show = show&"<a class='"&className&"' href='?"&Pid&"page="&EndPageNum+1&"' title='下十页'><font face='webdings'>8</font></a>"
end if
show = show& "] 页"
if page<>1 then
show = show&"<a class='"&className&"' href='?"&Pid&"page=1'> 首页</a> <a class='"&className&"' href='?"&Pid&"page="&page-1&"'>上一页</a>"
end if
if Pcount-page <> 0 then
show = show& "<a class='"&className&"' href='?"&Pid&"page="&page+1&"'> 下一页</a> <a class='"&className&"' href='?"&Pid&"page="&Pcount&"'>尾页</a>"
end if
show=show&"</tr></td>"
ThePage = show
end function
%>
<%
dim connstr
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("xinxi.mdb")
set conn=Server.CreateObject("AdoDb.Connection")
conn.Open connstr
%>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="560" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#1941A5">
<tr>
<td height="35" colspan="5" bgcolor="#D5D5D5"><div align="center">网络导航</div></td>
</tr>
<tr>
<td height="30" colspan="5"><a href="tianjia.asp" class="STYLE3">添加新记录</a></td>
</tr>
<%
set rs = server.createobject("adodb.recordset")
Sql="select * from biaoge Order by id Desc"
'分页参数设置
page = request.querystring("page")
if page = "" then page = 1
page = int(page)
Pnum = 20
className = "lwf"
PID = ""
'以下不变
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
Vcount = RS.recordcount
if RS.recordcount <> 0 then
RS.absoluteposition=RS.absoluteposition+((abs(page)-1)*Pnum)
end if
'********************************
i = 1
while not RS.eof and i<=Pnum
%>
<tr onMouseOver="this.bgColor='#FFFFCC' "onmouseout="this.bgColor='#ffffff'">
<td width="19%" height="28"><span class="STYLE2"><%=rs("name")%></span></td>
<td width="29%"><a href="http://<%=rs("url")%>" target="new" class="STYLE2"><%=rs("url")%></a></td>
<td width="29%"><span class="STYLE1"><%=rs("body")%></span></td>
<td width="12%"><div align="center" class="STYLE1"><a href="delete.asp?id=<%=rs("id")%>& action=del" onclick="return confirm('您确定要删除此营业点信息吗?')">删除</a></div></td>
<td width="11%"><div align="center" class="STYLE1"><a href="xiugai.asp?id=<%=rs("id")%>">修改</a></div></td>
</tr>
<%
rs.movenext
i = i + 1
wend
rs.close
set rs = nothing
%>
<tr>
<td width="19%" height="28" colspan="5"> <%=ThePage(Pid,page,Vcount,Pnum,className)%></td>
</tr>
</table>
</form>
<%
conn.close
set conn=Nothing
%>
</body>
展开全部
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询