关于查询结果后分页显示!
我现在想要把查询结果进行分页显示,每页显示10条记录,可是现在第一页是正常的.一点击下一页,就出错,各位领导,帮忙看下了,下面就是完整的代码!先谢下!!<html>
<head>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn_fj16.asp"-->
<!--#include file="admin_qx.asp" -->
<% isdl %>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
.style5 {color: #000000}
body,td,th {
font-size: 13px;
}
table {
word-break:break-all;
}
.STYLE7 {
font-size: 16px;
font-weight: bold;
}
.STYLE1 {color: #FF0000}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
body {
background-color: #d6dff7;
}
-->
</style>
<title>奶牛头数统计表</title>
</head>
<%
ID=trim(request("ID"))
nian=trim(request("nian"))
xiangzhen=trim(request("xiangzhen"))
cun=trim(request("cun"))
if nian<>"" and xiangzhen <>"" and cun="" then
sql="select * from nainiushuliangnianbao where nian='"&nian&"' and xiangzhen='"&xiangzhen&"' order by xiangzhen desc "
response.Write "<script language=javascript>{window.location.href='nainiushuliang_niaobao_list2.asp';}</script>"
end if
if nian<>"" and xiangzhen="" and cun=""then
sql="select * from nainiushuliangnianbao where nian='"&nian&"' order by xiangzhen desc"
end if
if nian<>"" and xiangzhen<>"" and cun<>"" then
sql="select * from nainiushuliangnianbao where nian='"&nian&"' and xiangzhen='"&xiangzhen&"' and cun='"&cun&"' order by xiangzhen desc"
end if
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,2
%>
<p align="center"> </p>
<p align="center"><span class="style4"> <%=DATE%>共<%=rs.recordcount%>条记录</span> 合计:
<%=total%>
头
</p>
<TABLE width=61% border=1 align="center" cellPadding=0 cellSpacing=0
borderColorLight=#6699ff borderColorDark=#ffffff bgcolor="#FFFFFF" style="border-collapse:collapse">
<tr>
<td width="63" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">序号</div></td>
<td width="80" align="center" nowrap="nowrap" bgcolor="#FFCC66">乡镇</td>
<td width="71" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">村组</div></td>
<td width="71" nowrap="nowrap" bgcolor="#FFCC66"><p align="center">日期</p></td>
<td width="83" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">期初</div></td>
<td width="80" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">自繁</div></td>
<td width="81" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">购入</div></td>
<td width="96" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">出卖</div></td>
<td width="84" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">死淘</div></td>
<td width="83" nowrap="nowrap" bgcolor="#FFCC66"><div align="center">实际增加</div></td>
<td width="106" nowrap="nowrap" bgcolor="#FFCC66"><p align="center">期末</p></td>
</tr>
<%count=0
sum=100
do while not rs.eof and count<rs.pagesize %>
<%if count Mod 2=0 then%><TR bgcolor="#E2EEFC" onMouseOver="this.style.backgroundColor='#FFDA6A'" onMouseOut="this.style.backgroundColor='#E2EEFC'">
<%end if%>
<td height="27" align="center" valign="middle" nowrap="nowrap"><%=count+1%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("xiangzhen")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("cun")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("nian")%>年</td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("qichu")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("zifan")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("gouru")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("chumai")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("sitao")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("shijizengjia")%></td>
<td align="center" valign="middle" nowrap="nowrap"><%=rs("qimo")%></td>
</tr>
<%rs.movenext
count=count+1
loop
%>
</table>
<span class="style4">共有<%=rs.recordcount%>条通过审核且不在回收站的记录,每页显示<%=rs.pagesize%>条 ,第<%=page%>/<%=rs.pagecount%>页
<%if page>1 then%>
<a href="nainiushuliang_nianbao_list2.asp?Page=<% = 1%>&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>">首页</a><a href="nainiushuliang_nianbao_list2.asp?Page=<% = 1%>"&key=<%=key%>&ziduan=<%=ziduan%>></a> <a href="nainiushuliang_nianbao_list2.asp?Page=<% =page -1 %>&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>">上一页</a><a href="nainiushuliang_nianbao_list2.asp?Page=<% =page -1 %>&key=<%=key%>&ziduan=<%=ziduan%>"></a>
<%end if %>
<%if page<>rs.pagecount then %>
<a href="nainiushuliang_nianbao_list2.asp?Page=<% =page + 1%>&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>">下一页</a><a href="nainiushuliang_nianbao_list2.asp?Page=<% =page + 1%>&key=<%=key%>&ziduan=<%=ziduan%>"></a> <a href="nainiushuliang_nianbao_list2.asp?Page=<% = rs.PageCount%>&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>">尾页</a><a href="nainiushuliang_nianbiao_list2.asp?Page=<% = rs.PageCount%>&key=<%=key%>&ziduan=<%=ziduan%>"></a></span>
<% end if %>
<select name="select2" id="select" onChange="javascript:window.location.href('nainiushuliang_niaobao_list2.asp?page='+this.options[this.selectedIndex].value+'&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>')">
<% for i=1 to rs.pagecount%>
<option value="<%=i%>" <%if i=page then response.Write("selected") end if%> ><%=i%> </option>
<% next%>
</select>
<span class="STYLE13">
<select name="pagesize" id="pagesize" onChange="javascript:window.location.href('nainiushuliang_nianbao_list2.asp?pagesize='+this.options[this.selectedIndex].value+'&key=<%=key%>&ziduan=<%=ziduan%>&by=<%=by%>')">
<% for iii=10 to 50 step 5%>
<option value="<%=iii%>" <%if iii=rs.pagesize then response.Write("selected") end if%> >每页显示<%=iii%>条记录</option>
<% next%>
<% for i=60 to 180 step 20%>
<option value="<%=i%>" <%if i=rs.pagesize then response.Write("selected") end if%> >每页显示<%=i%>条记录</option>
<% next%>
<% for ii=200 to 1000 step 200%>
<option value="<%=ii%>" <%if ii=rs.pagesize then response.Write("selected") end if%> >每页显示<%=ii%>条记录</option>
<% next%>
<option value="10000" <%if rs.pagesize=10000 then response.Write("selected") end if%> >每页显示10000条记录</option>
</select>
</span>
<div align="center"></div>
</body>
</html>