站内搜索asp代码
以下是搜索处理页面的代码,请帮我看看为什么能搜索却不能显示结果!谢谢!<script>functionbtn_ck_bh_Click(){varcx=document.f...
以下是搜索处理页面的代码,请帮我看看为什么能搜索却不能显示结果!谢谢!
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action="search.asp?cx="+cx;
}
</script>
<%
cx = request("cx")
dim pageCount
dim conn,rs,sql
page = cint(request("page"))
on error resume next
dbpath=server.MapPath("Date.mdb")
et conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
rs.open sql,conn,3,3
if cx <> "" then
'sql="select * from Books where Books_Name='"&request.Form("Books_Name")
sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
else
sql="select * from Books order by id desc"
end if
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!"
response.write errmsg
response.End()
end if
rs.pagesize=10
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
%>
<%
rs.movenext
numrows=numrows+1
wend
%>
<p align="center"><font color="#333333">共<%=pageCount%>页 第<%=page%>页
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<a href="search.asp?page=1&cx=<%=cx%>">首页</a>
<%end if%>
<%if page>1 then %><a href="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p=1
pagewhere=cint(request("pagewhere"))
pagewhere=pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p<>page then
%>
<a href="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%
end if
next
end if
%>
<%if page<pageCount then%>
<a href="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if%>下一页</a>
<%if page=pageCount then%>末页
<%end if%>
<%if page>pageCount then%>
<a href="search.asp?page=<%=pageCount%>&cx=<%=cx%>">
末页</a>
<%end if%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
<script>
function btn_ck_bh_Click()
{
var cx = document.form1.cxsj.value;
form1.action="search.asp?cx="+cx;
}
</script>
<%
cx = request("cx")
dim pageCount
dim conn,rs,sql
page = cint(request("page"))
on error resume next
dbpath=server.MapPath("Date.mdb")
et conn=server.CreateObject("adodb.connection")
set rs=server.CreateObject("adodb.recordset")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
rs.open sql,conn,3,3
if cx <> "" then
'sql="select * from Books where Books_Name='"&request.Form("Books_Name")
sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
else
sql="select * from Books order by id desc"
end if
if rs.bof then
errmsg=errmsg+"<br>"+"<li>"+keyword+"没有记录,请返回!"
response.write errmsg
response.End()
end if
rs.pagesize=10
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
%>
<%
rs.movenext
numrows=numrows+1
wend
%>
<p align="center"><font color="#333333">共<%=pageCount%>页 第<%=page%>页
<%if page=1 then%>首页<%end if%>
<%if page>1 then%>
<a href="search.asp?page=1&cx=<%=cx%>">首页</a>
<%end if%>
<%if page>1 then %><a href="search.asp?page=<%=page-1%>&cx=<%=cx%>"><%end if%>上一页</a>
<%
dim pagewhere
dim p
p=1
pagewhere=cint(request("pagewhere"))
pagewhere=pageCount
if pagewhere>0 then
for p=1 to pagewhere
if p<>page then
%>
<a href="search.asp?page=<%=p%>&cx=<%=cx%>"><%=p%></a>
<%
end if
next
end if
%>
<%if page<pageCount then%>
<a href="search.asp?page=<%=page+1%>&cx=<%=cx%>">
<%end if%>下一页</a>
<%if page=pageCount then%>末页
<%end if%>
<%if page>pageCount then%>
<a href="search.asp?page=<%=pageCount%>&cx=<%=cx%>">
末页</a>
<%end if%>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%> 展开
展开全部
楼主:
(1)page = cint(request("page"))
(2)on error resume next
(3)dbpath=server.MapPath("Date.mdb")
(4)et conn=server.CreateObject("adodb.connection")
(5)set rs=server.CreateObject("adodb.recordset")
(6)conn.open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
这段代码中的第(4)句前面应该是 set conn吧,你少了个s
(1)if cx <> "" then
(2)'sql="select * from Books where Books_Name='"&request.Form ("Books_Name")
(3)sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
(4)else
(5)sql="select * from Books order by id desc"
(6)end if
这段代码中第二句有一个注释符号不知道是楼主故意注释掉的还是不小心打上去的。
本人也只是学了一点皮毛,不知道楼主建立数据集的代码这样写有没有错,我就发表下我的写法吧,和楼主的比只是语句的顺序换了一下:
链接数据库的:
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("Date.mdb")
set conn=server.CreateObject("adodb.connection")
conn.open connstr
建立数据集的:
if cx<>"" then
sql="select * from Books where Books_Name='"&request.Form("Books_Name")
sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
else
sql="select * from Books order by id desc"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,3
以上只是个人的一些写法,个人认为这样写比较清楚一点,希望能帮到楼主
(1)page = cint(request("page"))
(2)on error resume next
(3)dbpath=server.MapPath("Date.mdb")
(4)et conn=server.CreateObject("adodb.connection")
(5)set rs=server.CreateObject("adodb.recordset")
(6)conn.open "provider=microsoft.jet.oledb.4.0;data source="&dbpath
这段代码中的第(4)句前面应该是 set conn吧,你少了个s
(1)if cx <> "" then
(2)'sql="select * from Books where Books_Name='"&request.Form ("Books_Name")
(3)sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
(4)else
(5)sql="select * from Books order by id desc"
(6)end if
这段代码中第二句有一个注释符号不知道是楼主故意注释掉的还是不小心打上去的。
本人也只是学了一点皮毛,不知道楼主建立数据集的代码这样写有没有错,我就发表下我的写法吧,和楼主的比只是语句的顺序换了一下:
链接数据库的:
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.MapPath("Date.mdb")
set conn=server.CreateObject("adodb.connection")
conn.open connstr
建立数据集的:
if cx<>"" then
sql="select * from Books where Books_Name='"&request.Form("Books_Name")
sql="select * from Books where Books_Name like'%"&cx&"%' order by id desc"
else
sql="select * from Books order by id desc"
end if
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,3,3
以上只是个人的一些写法,个人认为这样写比较清楚一点,希望能帮到楼主
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if page = 0 then
page = 1
end if
改成
if page = "" then '此处改
page = 1
end if
试试 我也不清楚
page = 1
end if
改成
if page = "" then '此处改
page = 1
end if
试试 我也不清楚
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
http://h.8wa.com 福娃免费空间
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询