增加“项目分页显示”代码

谁帮我在以下页面代码里增加“项目分页显示”代码,一页只显示8个项目,多的项目移到下一页,然后做“首页上一页下一页尾页”这样的代码。谢谢!做好了再加100分。<!--#in... 谁帮我在以下页面代码里增加“项目分页显示”代码,一页只显示8个项目,多的项目移到下一页,然后做“首页 上一页 下一页 尾页”这样的代码。谢谢!做好了再加100分。
<!--#include file="top.asp"-->
<table width="775" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td width="170" height="300" valign="top" bgcolor="efefef"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="center" bgcolor="#B9DCFF"><span class="STYLE6">新闻搜索</span></td>
</tr>
<tr>
<td><table width="100%" height="80" border="0" cellpadding="0" cellspacing="0">
<form name="form1" method="get" action="search.asp">
<tr>
<td height="30" align="center" bgcolor="#efefef"> <input type="text" name="key" size="19" class="input"> </td>
</tr>
<tr>
<td height="30" align="center" bgcolor="#efefef"> <select name="otype" class="input">
<option value="title" selected class="input">新闻标题</option>
<option value="msg" class="input">新闻内容</option>
</select>

<input type="submit" name="Submit" value="搜索" class="input"></td>
</tr>
</form>
</table></td>
</tr>
</table>
</td>
<td width="600" align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" bgcolor="#BDDFFF"> <span class="STYLE7">
</span> </td>
</tr>
</table><%set rs=server.CreateObject("adodb.recordset")
sql="select * from picture order by id desc"
rs.open sql,conn,1,1%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%row_count=1 %>
<tr><%if rs.eof and rs.bof then
response.write (" ")
else
randomize
Num=(int(rnd()*802)+1)
i=Num
Do While Not rs.EOF%>
<td height="201"><table width="140" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="50" align="center"><a href="viewpic.asp?id=<%=rs("id")%>" target="_blank"><img src="<%=rs("b_pic")%>" alt="" width="120" height="130" border="0"></a></td>
</tr>
<tr>
<td height="22" align="center"><a href="viewpic.asp?id=<%=rs("id")%>" target="_blank">
<%=left(rs("s_text"),6)%></a></td>
</tr>

</table></td> <% if row_count mod 4 =0 then%>
</tr><%end if
rs.MoveNext
row_count=row_count+1
i=i+375
Loop
rs.close
end if%>
</table></td>
</tr>
</table><!--#include file="bottom.asp"-->
展开
 我来答
小鬼翊
2008-05-22 · TA获得超过396个赞
知道小有建树答主
回答量:274
采纳率:0%
帮助的人:240万
展开全部
我现在也在学这个
拿个例子不停的删 删到最后留下的程序符合分页及翻页的要求

<!--#include file="include/conn.asp"--> '连接数据库
<%
set rs=server.createobject("adodb.recordset")
sql="select * from tab_article where Aclass=1" '改表名和查询的条件

rs.open sql,conn,3
rs.pagesize=20 '每页多少条记录
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
for i=0 to rs.pagesize-1
if rs.bof or rs.eof then exit for
%>
<tr>
<td><img src="images/huidian.jpg"></td>
<td><%=rs("Atitle")%></td>
<td><%=rs("Adate")%></td>
</tr>
<%
rs.movenext()
next
%>
</table>
<p align="center">
<a href="research_1.asp">首页</a>  '把连接的文件改下

<a href="research_1.asp?page=<%=epage-1%>">前一页</a> 
<a href="research_1.asp?page=<%=epage+1%>">后一页</a> 
<a href="research_1.asp?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>
<%
conn.close()
%>

不好意思啊 给你提供一个最简单的例子
我自己的就是参照这样做出来的

BOF 属性:目前指标指到 RecordSet 的第一笔。

EOF 属性:目前指标指到 RecordSet 的最后一笔。

Move 方法:移动指标到 RecordSet 中的某一条记录。

AbsolutePage 属性:设定当前记录的位置是位于哪一页 AbsolutePosition 属性:目前指标在 RecordSet 中的位置。

PageCount 属性:显示 Recordset 对象包括多少“页”的数据。

PageSize 属性:显示 Recordset 对象每一页显示的记录数。

RecordCount 属性:显示 Recordset 对象记录的总数。

加上这些参数的解释 上面的应该就都能看懂了
:)
阳光上的桥
2008-05-22 · 知道合伙人软件行家
阳光上的桥
知道合伙人软件行家
采纳数:21423 获赞数:65833
网盘是个好东东,可以对话和传文件

向TA提问 私信TA
展开全部
<!--#include file="top.asp"-->
<table width="775" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<table width="775" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td width="170" height="300" valign="top" bgcolor="efefef"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" align="center" bgcolor="#B9DCFF"><span class="STYLE6">新闻搜索</span></td>
</tr>
<tr>
<td><table width="100%" height="80" border="0" cellpadding="0" cellspacing="0">
<form name="form1" method="get" action="search.asp">
<tr>
<td height="30" align="center" bgcolor="#efefef"> <input type="text" name="key" size="19" class="input"> </td>
</tr>
<tr>
<td height="30" align="center" bgcolor="#efefef"> <select name="otype" class="input">
<option value="title" selected class="input">新闻标题</option>
<option value="msg" class="input">新闻内容</option>
</select>

<input type="submit" name="Submit" value="搜索" class="input"></td>
</tr>
</form>
</table></td>
</tr>
</table>
</td>
<td width="600" align="center" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" bgcolor="#BDDFFF"> <span class="STYLE7">
</span> </td>
</tr>
</table><%set rs=server.CreateObject("adodb.recordset")
sql="select * from picture order by id desc"
rs.open sql,conn,1,1%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%row_count=1 %>
<tr><%if rs.eof and rs.bof then
response.write (" ")
else
randomize
Num=(int(rnd()*802)+1)
i=Num

'我增加的第一段
rs.pagesize=8
if request("page")<>"" then
epage=cint(request("page"))
if epage<1 then epage=1
if epage>rs.pagecount then epage=rs.pagecount
else
epage=1
end if
rs.absolutepage=epage

Do While Not rs.EOF%>
<td height="201"><table width="140" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="50" align="center"><a href="viewpic.asp?id=<%=rs("id")%>" target="_blank"><img src="<%=rs("b_pic")%>" alt="" width="120" height="130" border="0"></a></td>
</tr>
<tr>
<td height="22" align="center"><a href="viewpic.asp?id=<%=rs("id")%>" target="_blank">
<%=left(rs("s_text"),6)%></a></td>
</tr>

</table></td> <% if row_count mod 4 =0 then%>
</tr><%end if
rs.MoveNext
row_count=row_count+1
i=i+375
Loop
rs.close
end if%>
</table></td>
</tr>
</table>

<!--我增加的第二段-->
<p align="center">
<a href="">首页</a> 
<a href="?page=<%=epage-1%>">前一页</a> 
<a href="?page=<%=epage+1%>">后一页</a> 
<a href="?page=<%=rs.pagecount%>">末页</a>
</p>
<p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p>

<!--#include file="bottom.asp"-->
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式