
增加“项目分页显示”代码
谁帮我在以下页面代码里增加“项目分页显示”代码,一页只显示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"--> 展开
<!--#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"--> 展开
展开全部
我现在也在学这个
拿个例子不停的删 删到最后留下的程序符合分页及翻页的要求
<!--#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 对象记录的总数。
加上这些参数的解释 上面的应该就都能看懂了
:)
拿个例子不停的删 删到最后留下的程序符合分页及翻页的要求
<!--#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 对象记录的总数。
加上这些参数的解释 上面的应该就都能看懂了
:)
展开全部
<!--#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"-->
<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"-->
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询