ASP搜索分页问题
出来搜索结果后,如果分多页显示,点击下一页时就出现全部数据库的内容,收不到上一页传递过来的查询关键字,请高手看一下哪里出错了。<script>functionbtn_ck...
出来搜索结果后,如果分多页显示,点击下一页时就出现全部数据库的内容,收不到上一页传递过来的查询关键字,请高手看一下哪里出错了。
<script>
function btn_ck_bh_Click()
{
var cx = document.form.cxsj.value;
form.action ="search.asp?cx="+cx;
}
</script>
<form method="POST" name="form" action=search.asp>
<p>请输入查询内容:
<input type="text" name="cxsj" size="50" ><input type="submit" value="搜索" name="B1" LANGUAGE="javascript" onClick="btn_ck_bh_Click()">
</form>
cx = Request.QueryString("cx")
dim pageCount
page = cint(request("page"))
set rs=server.createobject("adodb.recordset")
if cx <> "" then
sql = "select * from peijian where name like '%"&cx& "%' or oem like '%"&cx&"%' or cexing like '%"&cx&"%' order by id desc"
else
sql ="select * from peijian order by id desc"
end if
rs.open sql,conn,1,1
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
RS.PageSize=20
pageCount = cint(rs.pageCount)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
WHILE NOT RS.EOF AND NumRows<RS.PageSize %>
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=1"> 首页</a>
<%end if%>
<%if page>1 then%><a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=page-1%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
//把pagewhere转换成整数
//pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=p%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=page+1%>">
<%end if %>下一页</a>
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=PageCount%>"> 尾页</a>
<%end if%> 展开
<script>
function btn_ck_bh_Click()
{
var cx = document.form.cxsj.value;
form.action ="search.asp?cx="+cx;
}
</script>
<form method="POST" name="form" action=search.asp>
<p>请输入查询内容:
<input type="text" name="cxsj" size="50" ><input type="submit" value="搜索" name="B1" LANGUAGE="javascript" onClick="btn_ck_bh_Click()">
</form>
cx = Request.QueryString("cx")
dim pageCount
page = cint(request("page"))
set rs=server.createobject("adodb.recordset")
if cx <> "" then
sql = "select * from peijian where name like '%"&cx& "%' or oem like '%"&cx&"%' or cexing like '%"&cx&"%' order by id desc"
else
sql ="select * from peijian order by id desc"
end if
rs.open sql,conn,1,1
'如果没有数据记录
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!!"
response.write errmsg
response.end
end if
RS.PageSize=20
pageCount = cint(rs.pageCount)
if page = 0 then
page =1
end if
RS.AbsolutePage = page
x=1
WHILE NOT RS.EOF AND NumRows<RS.PageSize %>
<p align="center"><FONT color=#333333>共<%=PageCount%>页 第<%=page%>页
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=1"> 首页</a>
<%end if%>
<%if page>1 then%><a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=page-1%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p = 1
//把pagewhere转换成整数
//pagewhere = cint(request("pagewhere"))
pagewhere = pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p <> page then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=p%>"><%=p%></a>
<%end if
if p =page then%>
<%=p%>
<% end if
next
end if%>
<%if page < PageCount then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=page+1%>">
<%end if %>下一页</a>
<%if page=PageCount then%>尾页
<%end if%>
<%if page<PageCount then%>
<a href="search.asp?cx=<%Request.QueryString("cxsj")%>&page=<%=PageCount%>"> 尾页</a>
<%end if%> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询