我自己写的一个分页程序,出错了,请大家指导! <!--#include file="conn.asp"--> <head> <meta http-equiv="Content-Language" content="zh-cn"> </head> <% sql="select * from allbook order by id desc" set rs=server.createobject("adodb.recordset") rs.open sql,conn,1,1 if rs.recordcount=0 then 'rs.recordcount 所有记录数' response.write("数据库没有相关信息") else pgsz=5 rs.pagesize=cint(pgsz) totel=rs.recordcount pagecount=int(totel/pgsz*-1)*-1 pageno=request("pageno") 'pageno为当前页 if pageno="" then pageno=1 end if end if bookbegin=pgsz*(pageno-1)+1 'bookbegin为rs指向的第一条记录的开始 if pgsz*pageno>totel-bookbegin then bookend=totel-bookbegin else bookend=pgsz*pageno end if %> <% if pageno>1 then '我觉得这个判断有问题 rs.move [pgsz*(pageno-1)-1] end if for i=bookbegin to bookend %> <div align="center"> <table cellpadding="0" cellspacing="0" width="770" height="119"> <!-- MSTableType="layout" --> <tr> <td valign="middle"> 书名:<%=rs("bookname")%></td> <td width="97"> 作者:<%=rs("zuozhe")%></td> <td width="173"> 出版社:<%=rs("chubanshe")%></td> <td width="140"> 出版时间:<%=rs("outtime")%></td> <td width="123"> 类别:<%=rs("leibie")%></td> <td height="23" width="117"> 价钱:<%=rs("piece")%></td> </tr> <tr> <td valign="top" width="120"> </td> <td valign="top" colspan="5" height="96"> <table style="table-layout:fixed" border="0" width="100%" cellspacing="0" cellpadding="0" id="table1"> <tr> <td width="61" style="word-break:break-all" valign="top">简介:</td> <td><%=rs("jianjie")%></td> </tr> </table> </td> </tr> </table> </div> <%rs.movenext next%> <div align="center"> <table cellpadding="0" cellspacing="0" width="770" height="20"> <!-- MSTableType="layout" --> <tr> <td valign="top" height="20" width="770"><a href="fenye1.asp?pageno"> <span style="text-decoration: none">第一页</span></a>| <% if pagecount>1 then a=pageno-1 b=pageno+1 if a>0 then response.write "<a href=fenye1.asp?pageno=" response.write a response.write "><<<</a>| " end if for i=1 to pagecount response.write "<a href=fenye1.asp?pageno=" response.write i response.write ">" response.write i response.write"</a> " next if pageno<>pagecount then '为什么当pageno=pagecount时 >>>还会出现? response.write " |<a href=fenye1.asp?pageno=" response.write b response.write ">>>></a> |" end if response.write "<a href=fenye1.asp?pageno=" response.write pagecount response.write "><span style='text-decoration: none'>最后一页</span></a>" end if %> <% rs.close set rs=nothing %> <% closeconn %></td> </tr> </table> </div> 当pgsz=5时,3,4是空的,1,2页有内容,(共4页) 当pgsz=10时,1页有内容,2页是空的,(共2页) 不解?