求助“关于产品模糊搜索问题”

any88 2007-04-14 12:57:04
大家好!请高手指点,原产品网站不能模糊搜索,一定要输入关键词才行的。想不输入即可搜索,麻烦各位啦!以下是一些代码:(网站为:www.gzpk.cn 左边“产品搜索”那里)

if keyword<>"" then
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
end if
strField=trim(request("Field"))

if request("page")<>"" then
currentPage=cint(request("page"))
else


麻烦发EMAIL给我或加我QQ交流哦。binhua99@163.com QQ:50261397
...全文
357 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
any88 2007-04-21
  • 打赏
  • 举报
回复
小弟在此,非常感谢以上各位仁兄的帮助,已解决,希望以后能与你们多多联系!互相交流哦!我的QQ:50261397 (不要盗我哦.:))
jokeD 2007-04-18
  • 打赏
  • 举报
回复
你可以判断 如果提交为"",就定一个变量 附值一个固定关键字,搜出大类不就可以达到目的了吗
silinee 2007-04-17
  • 打赏
  • 举报
回复
在if keyword<>"" then 前加一行

if keyword="关键字" then keyword=""
zsh6709 2007-04-17
  • 打赏
  • 举报
回复
间接调用其他几个function来做搜索吧
hll_1818 2007-04-17
  • 打赏
  • 举报
回复
你都没有搜索的语句啊????在serch.asp里??
any88 2007-04-16
  • 打赏
  • 举报
回复
是的,两个文件是独立的,一个是search.asp,另一个是syscode.asp 麻烦各位啦!谢谢!
any88 2007-04-15
  • 打赏
  • 举报
回复
大家好!还是不行哦。我把原完整的代码放上来,麻烦各位帮我看看

以下是syscode.asp文件

<%
dim strFileName,MaxPerPage,ShowSmallClassType
dim totalPut,CurrentPage,TotalPages
dim BeginTime,EndTime
dim founderr, errmsg
dim BigClassName,SmallClassName,SpecialName,keyword,strField
dim rs,sql,sqlArticle,sqlDown,rsArticle,rsDown,sqlSearch,rsSearch,sqlBigClass,rsBigClass,sqlBigClass_Down,sqlSpecial,rsSpecial
dim SpecialTotal
BeginTime=Timer
BigClassName=Trim(request("BigClassName"))
SmallClassName=Trim(request("SmallClassName"))
SpecialName=trim(request("SpecialName"))
keyword=trim(request("keyword"))
if keyword<>"" then
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
end if
strField=trim(request("Field"))

if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if

sqlBigClass="select * from BigClass order by BigClassID"
Set rsBigClass= Server.CreateObject("ADODB.Recordset")
rsBigClass.open sqlBigClass,conn,1,1

sqlBigClass_Down="select * from BigClass_Down order by BigClassID"
Set rsBigClass_Down= Server.CreateObject("ADODB.Recordset")
rsBigClass_Down.open sqlBigClass_Down,conn,1,1


'=================================================
'过程名:ShowSearchTerm
'作 用:显示搜索条件信息
'参 数:无
'=================================================
sub ShowSearchTerm()
response.write "| 产品搜索 >> "
if BigClassName<>"" then
response.write "<a href='Product.asp?BigClassName=" & BigClassName & "'>" & BigClassName & "</a> >> "
if SmallClassName<>"" then
response.write "<a href='Product.asp?BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName & "'>" & SmallClassName & "</a> >> "
else
response.write "所有小类 >> "
end if
end if
if keyword<>"" then
select case strField
case "Title"
response.Write "名称中含有 <font color=red>"&keyword&"</font> 的产品"
case "Content"
response.Write "说明含有 <font color=red>"&keyword&"</font> 的产品"
case else
response.Write "名称中含有 <font color=red>"&keyword&"</font> 的产品"
end select
else
response.write " 所有产品"
end if
end sub

______________________________________________________

以下为search.asp文件:

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<%
ShowSmallClassType=ShowSmallClassType_Search
MaxPerPage=MaxPerPage_Search
strFileName="Search.asp?Field=" & strField & "&Keyword=" & keyword & "&BigClassName=" & BigClassName & "&SmallClassName=" & SmallClassName
%>
<!-- #include file="Head.asp" -->
<table width="100%" height="8" border="0" cellpadding="0" cellspacing="0" background="Img/contopbg.gif">
<tr>
<td><table width="226" height="8" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="209"></td>
<td width="17" background="Img/contopbg2.gif"></td>
</tr>
</table></td>
</tr>
</table>
<BODY bgColor=#666666 leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="209" align="center" valign="top"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td ><img src="Img/login.gif" alt="ó??§μ???" width="196" height="32"></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="10" align="center"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="Img/left1.gif" width="187" height="19"></td>
</tr>
<tr>
<td background="Img/left2.gif"><table width="90%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td align="center">
<% call ShowUserLogin() %></td>
</tr>
</table></td>
</tr>
<tr>
<td><img src="Img/left3.gif" width="187" height="20"></td>
</tr>
</table></td>
</tr>
<tr>
<td height="5"></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
<tr>
<td><img src="Img/sotop.gif" width="205" height="41"></td>
</tr>
<tr>
<td align="center" background="Img/sobg.gif"><table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<% call ShowSearch(1) %>
</td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><img src="Img/sotb.gif" width="205" height="6"></td>
</tr>
</table>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"></td>
</tr>
<tr>
<td>
<div align="center">
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
<tr>
<td><img src="Img/shang.gif" width="203" height="33"></td>
</tr>
</table>
<table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<% call ShowSmallClass_Tree() %>
</td>
</tr>
</table>
</div></td>
</tr>
<TR>
<TD
height=3 colspan="2"></TD>
</TR>
</table>
<p> </p>
<p> </p></td>
<td width="17" background="Img/combg.gif"> </td>
<td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="2"></td>
</tr>
<tr>
<td height="26">  <span >  <img src="Img/HaoSc23.png" width="14" height="16" align="absmiddle"> <span class="tt_16">产 品 搜 索</span></span></td>
</tr>
<tr>
<td height="2" bgcolor="#CBE0E9"></td>
</tr>
</table></td>
</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="453"
height=28>
<% call ShowClassGuide() %>
</td>
<td width="102">
<% call ShowArticleTotal() %>
</td>
</tr>
<tr>
<td
height=1 colspan="2" background=img/naBialym.gif><img height=1 src="img/1x1_pix.gif"
width=10></td>
</tr>
<tr>
<td
height=1 colspan="2">
<% call ShowSearchResult() %>
</td>
</tr>
<tr>
<td
height=1 colspan="2">
<%
if totalput>0 then
call showpage(strFileName,totalput,MaxPerPage,false,true,"个产品")
end if
%>
</td>
</tr>
</table></td>
</tr>
</table>

麻烦各位大侠们帮忙啦!网站是www.gzpk.cn 左边的“产品搜索”框
any88 2007-04-15
  • 打赏
  • 举报
回复
非常感谢,非常感谢!我试试去!再次谢谢!
hll_1818 2007-04-15
  • 打赏
  • 举报
回复
syscode.asp文件是单独的吗??
hll_1818 2007-04-15
  • 打赏
  • 举报
回复
你都没有搜索的语句啊????在serch.asp里??
飞天神笔 2007-04-14
  • 打赏
  • 举报
回复
看了你的网站,应该在你上面那段程序前加这么一条语句

if keyword="关键字" then keyword=""
飞天神笔 2007-04-14
  • 打赏
  • 举报
回复
if keyword="" or keyword="关键字" then
sql = "select * from <tablename>"
else
keyword=replace(replace(replace(replace(keyword,"'","‘"),"<","<"),">",">")," "," ")
sql = "select * from <tablename> where <fieldsname>='" & keyword & "'"
end if
Fufay 2007-04-14
  • 打赏
  • 举报
回复
不明白你要什么,看了你的网站,不输入关键字不是可以搜索么?
any88 2007-04-14
  • 打赏
  • 举报
回复
但我试过了呀。都不行呀。麻烦大侠们帮助哦。可以参看www.gzpk.cn 左边的产品搜索框即是哦。谢谢!
piperzero 2007-04-14
  • 打赏
  • 举报
回复
怎么不可以啊,你看到默认是“关键字”。如果不输入就传递进去了。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧