这是一段条件搜索代码,执行第一次(搜索结果第一页)时正常,问题出在无法显示第2页及以后的搜索结果,点击“下一页”,不显示任何搜索结果。以下是代码:
<!--#include file="inc/userconn.inc" -->
<%on error resume next%>
<%
sql = "select * from trade order by id "
set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,1,1
%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("trade"))%>","<%= trim(rs("bigtrade"))%>","<%= trim(rs("trade"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count%>;
function changelocation(bigtrade)
{
document.search.trade.length = 0;
var bigtrade=bigtrade;
var i;
document.search.trade.options[0] = new Option('请选择二级分类','');
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == bigtrade)
{
document.search.trade.options[document.search.trade.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
</script>
<html>
<head>
<title>名录</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/guhongying.css" type="text/css">
<style type="text/css">
<!--
a:link {
color: #000099;
text-decoration: underline;
}
a:visited {
color: #990000;
text-decoration: underline;
}
a:hover {
color: #000099;
text-decoration: underline;
}
a:active {
text-decoration: underline;
}
-->
</style></head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="780" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="633" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="534" bgcolor="#EFEFF7">
<table width="120%" border="0" cellspacing="0" cellpadding="0">
<form action="search.asp" method="post" name="search">
<tr>
<td>公司名称:
<input maxlength=30 name=comp size=15 class="form">
<font color=#ffffff>
<select class=form name=city >
<option value="">-请选择所在地区-</option>
<option value=安徽省>安徽省</option>
<option value=北京市>北京市</option>
<option value=重庆市>重庆市</option>
<option value=福建省>福建省</option>
<option value=广东省>广东省</option>
<option value=广西省>广西省</option>
<option value=贵州省>贵州省</option>
<option value=甘肃省>甘肃省</option>
<option value=河北省>河北省</option>
<option value=河南省>河南省</option>
<option value=湖南省>湖南省</option>
<option value=湖北省>湖北省</option>
<option value=黑龙江省>黑龙江省</option>
<option value=海南省>海南省</option>
<option value=吉林省>吉林省</option>
<option value=江苏省>江苏省</option>
<option value=江西省>江西省</option>
<option value=辽宁省>辽宁省</option>
<option value=宁夏>宁夏</option>
<option value=内蒙>内蒙古</option>
<option value=青海省>青海省</option>
<option value=上海市>上海市</option>
<option value=四川省>四川省</option>
<option value=山东省>山东省</option>
<option value=山西省>山西省</option>
<option value=陕西省>陕西省</option>
<option value=天津市>天津市</option>
<option value=西藏省>西藏省</option>
<option value=新疆省>新疆省</option>
<option value=云南省>云南省</option>
<option value=浙江省>浙江省</option>
<option value=香港>香港</option>
<option value=澳门>澳门</option>
<option value=台湾>台湾</option>
<option value=国外>国外</option>
</select>
</font>
<select name="bigtrade" onChange="changelocation(document.search.bigtrade.options[document.search.bigtrade.selectedIndex].value)">
<option value="酒水名录">酒水名录</option></select><select name="trade">
<option selected value="">请选择二级分类</option>
</select><font color=#ffffff><input type="image" border="0" name="imageField2" src="image/search.gif">
<%
sql="select * from bigtrade"
set rs=server.createobject("ADODB.Recordset")
rs.open sql,conn,1,1
while not rs.eof
%>
<%
rs.movenext
wend
rs.Close()
%> </tr>
</table> </td>
</tr>
<tr><td height="4"></td></tr>
</table>
<table border="0" cellspacing="1" cellpadding="0" align="center" width="100%" bgcolor="#006699">
<tr bgcolor="#FFFFFF">
<td height="22" width="60" background="image/yellowp3-bg.gif"> </td>
<td width="400" background="image/yellowp3-bg.gif">
<div align="center"><b>企 业 名 称</b></div>
</td>
<td width="90" background="image/yellowp3-bg.gif">
<div align="center"><b>联 系 人</b></div>
</td>
<td background="image/yellowp3-bg.gif">
<div align="center"><b>推 荐</b></div>
</td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="0" align="center" width="100%" bgcolor="#CCCCCC">
<%
trade=request("trade")
sql="select * from comp where trade='"&trade&"' and icheck=True order by imember"
Set rs=Server.CreateObject("ADODB.RecordSet")
rs.open sql,conn,1,1
n=0
if not isempty(request("page")) then
pagecount=cint(request("page"))
else
pagecount=1
end if
rs.pagesize=15
rs.AbsolutePage=pagecount
do while not rs.eof
%>
<tr bgcolor="#E2EDF1">
<td width="60" height="20">
<div align="center"><%if rs("ichecktime")=date() then%>
<%end if%></div>
</td>
<td width="400"> <a href="showcomp.asp?id=<%=rs("id")%>"><%=rs("company")%></a></td>
<td width="90">
<div align="center"><%=rs("name")%></div>
</td>
<td>
<div align="center"> <%if rs("imember")=True then response.write "∧"%>
</div>
</td>
</tr>
<%
rs.movenext
n=n+1
if n>=rs.pagesize then exit do
loop
%>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form action="showtrade2.asp" method="post">
<tr bgcolor="#B0CCDC">
<td height="35" bgcolor="#B0CCDC">
<div align="center"> 共 <b><%=rs.recordcount%></b> 条记录, 页次: <b><font color=red><%=pagecount%></font>/<%=rs.pagecount%></b>,
当前从第 <%
if pagecount<=1 then
response.write "<font color=red>1</font>"
else
response.write "<font color=red>" & pagecount*rs.pagesize-rs.pagesize+1 & "</font>"
end if
%> 条开始。 <% if pagecount=1 and rs.pagecount<>pagecount and rs.pagecount<>0 then%>
<a href="showtrade.asp?trade=<%=trade%>&page=<%=cstr(pagecount+1)%>">[下一页]</a>
<img src="image/yellowp3-arrowlast.gif" width="9" height="8">
<% end if %> <% if rs.pagecount>1 and rs.pagecount=pagecount then %>
<img src="image/yellowp3-arrowfirst.gif" width="9" height="8">
<a href="showtrade.asp?trade=<%=trade%>&page=<%=cstr(pagecount-1)%>">
[上一页]</a> <%end if%> <% if pagecount<>1 and rs.pagecount<>pagecount then%>
<img src="image/yellowp3-arrowfirst.gif" width="9" height="8">
<a href="showtrade.asp?trade=<%=trade%>&page=<%=cstr(pagecount-1)%>">
[上一页]</a> <a href="showtrade.asp?trade=<%=trade%>&page=<%=cstr(pagecount+1)%>">
[下一页]</a> <img src="image/yellowp3-arrowlast.gif" width="9" height="8">
<% end if%>
直接到第
<select name="page">
<%for i=1 to rs.pagecount%>
<option value="<%=i%>"><%=i%></option>
<%next%>
</select>
页
<input type="submit" name="go" value="Go">
<input type="hidden" name="trade" value="<%=trade%>">
<%
rs.close
set rs=nothing
%>
</div>
</td>
</tr></form>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td height="20"> </td>
</tr>
<tr>
<td height="20"> </td>
</tr>
</table>
</td>
<td width="147" valign="top"> </td>
</tr>
<tr>
<td colspan="2" height="4" bgcolor="#006699"></td>
</tr>
</table>
<script language="javascript">
changelocation(document.search.bigtrade.options[document.search.bigtrade.selectedIndex].value);
</script>
</body>
</html>