上一页、下一页中遇到奇怪的问题

thunderingman 2008-11-04 08:26:08
if request("query")="books_of_type" then
booktype=request("booktype")
if booktype<>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from book where booktype='"&booktype&"' order by id asc"
rs.open sql,db,1,3
if rs.eof or rs.bof then
response.write "<script>alert('该分类没有图书!');history.go(-1)</script>"
else
i=1
rs.pagesize=10
pagecount1=rs.pagecount
if request.querystring("pagenum")=0 or request.querystring("pagenum")="" then
pagenum=1
else
pagenum=trim(request("pagenum"))
rs.absolutepage=trim(request("pagenum"))
end if
%>


<div align="center" class="STYLE1"><strong>[<%=rs("booktype")%>]分类下的书
</strong></div>
<br>
<table width="88%" border="0" align="center" cellspacing="0">
<tr align="center" valign="middle" >
<td align="center" class="2">图书名称</td>
</tr>
<%do while not rs.eof and i<=rs.pagesize %>
<tr align="center">
<td height="26"><a href="book.asp?query=one_book&bookname=<%=rs
("bookname")%>"><font color="#0000ff"><%=rs("bookname")%></font></a></td>
</tr>
<%
i=i+1
rs.movenext
loop
%>
</table>
<p align="center">共<%=rs.pagecount%>页,当前<%=pagenum%>/<%=rs.pagecount%> <a
href=book.asp?query=books_of_type&booktype=<%=rs("booktype")%>&pagenum=1>首页</a>
<%if pagenum>1 then%>
<a href=book.asp?query=books_of_type&booktype=<%=rs("booktype")%>&pagenum=<%=
(pagenum-1)%>>上一页</a>
<%else%>
上一页
<%end if%>
<%if pagenum < trim(pagecount1) then%>
<a href=book.asp?query=books_of_type&booktype=<%=rs("booktype")%>&pagenum=<%=
(pagenum+1)%>>下一页</a>
<%else%>
下一页
<%end if%>
<a href=book.asp?query=books_of_type&booktype=<%=rs("booktype")%>&pagenum=<%
=pagecount1%>>尾页</a>
</p>

<%end if
else
response.write "<script>alert('未选定类型!');window.location.href='book.asp?
query=all_type'</script>"
end if
%>
<%end if%>


上面是源程序,说明:booktype是指图书类型,比如“文学”、“计算机”等,上述源序实现的是查看某一图书类型下的全部书

现在的问题是如果显示到最后一页或直接按“尾页”到达显示的最后一页后,再按“首页”、“上一页”就会显示“未选定类型
即此时booktype是空的

请高手帮忙看看这是怎么回事啊?
...全文
44 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
<p align="center">共 <%=rs.pagecount%>页,当前 <%=pagenum%>/ <%=rs.pagecount%> <a
href=book.asp?query=books_of_type&booktype= <%=booktype%>&pagenum=1>首页 </a>
<%if pagenum>1 then%>
<a href=book.asp?query=books_of_type&booktype= <%=booktype%>&pagenum= <%=
(pagenum-1)%>>上一页 </a>
<%else%>
上一页
<%end if%>
<%if pagenum < trim(pagecount1) then%>
<a href=book.asp?query=books_of_type&booktype= <%=booktype%>&pagenum= <%=
(pagenum+1)%>>下一页 </a>
<%else%>
下一页
<%end if%>
<a href=book.asp?query=books_of_type&booktype= <%=booktype%>&pagenum= <%
=pagecount1%>>尾页 </a>
</p>
thunderingman 2008-11-04
  • 打赏
  • 举报
回复
还是一样
未选定类型
sy_binbin 2008-11-04
  • 打赏
  • 举报
回复
<a href=book.asp?query=books_of_type&booktype= <%=booktype%>&pagenum=1> 首页 </a>


你这样试试那
thunderingman 2008-11-04
  • 打赏
  • 举报
回复
刚才程序排版不大清楚
if request("query")="books_of_type" then
booktype=request("booktype")
if booktype <>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from book where booktype='"&booktype&"' order by id asc"
rs.open sql,db,1,3
if rs.eof or rs.bof then
response.write " <script>alert('该分类没有图书!');history.go(-1) </script>"
else
i=1
rs.pagesize=10
pagecount1=rs.pagecount
if request.querystring("pagenum")=0 or request.querystring("pagenum")="" then
pagenum=1
else
pagenum=trim(request("pagenum"))
rs.absolutepage=trim(request("pagenum"))
end if
%>


<div align="center" class="STYLE1"> <strong>[ <%=rs("booktype")%>]分类下的书
</strong> </div>
<br>
<table width="88%" border="0" align="center" cellspacing="0">
<tr align="center" valign="middle" >
<td align="center" class="2">图书名称 </td>
</tr>
<%do while not rs.eof and i <=rs.pagesize %>
<tr align="center">
<td height="26"> <a href="book.asp?query=one_book&bookname= <%=rs
("bookname")%>"> <font color="#0000ff"> <%=rs("bookname")%>
</font></a> </td>
</tr>
i=i+1
rs.movenext
loop
%>
</table>
<p align="center">共 <%=rs.pagecount%>页,当前 <%=pagenum%>/ <%=rs.pagecount%>
<a href=book.asp?query=books_of_type&booktype= <%=rs("booktype")%>&pagenum=1>
首页 </a>
if pagenum>1 then
<a href=book.asp?query=books_of_type&booktype= <%=rs("booktype")%
>&pagenum=<%=(pagenum-1)%>>上一页 </a>
else
上一页
end if
if pagenum < trim(pagecount1) then
<a href=book.asp?query=books_of_type&booktype= <%=rs("booktype")%
>&pagenum= <%=(pagenum+1)%>>下一页 </a>
else
下一页
end if
<a href=book.asp?query=books_of_type&booktype= <%=rs("booktype")%>&pagenum
=<%=pagecount1%>>尾页 </a>
</p>

end if
else
response.write " <script>alert('未选定类型!');window.location.href='book.asp?
query=all_type' </script>"
end if

end if


上面是源程序,说明:booktype是指图书类型,比如“文学”、“计算机”等,上述源序实现的是查看某一图书类型下的全部书

现在的问题是如果显示到最后一页或直接按“尾页”到达显示的最后一页后,再按“首页”、“上一页”就会显示“未选定类型”
即此时booktype是空的

请高手帮忙看看这是怎么回事啊?
huanghemajia 2008-11-04
  • 打赏
  • 举报
回复
帮顶!!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧