网站搜索没有后台搜索精确!如何把前台搜索和后台搜索改成一样的!
后台搜索比较精确!经常会出现同一个关键字,后台可以搜索到几十个代码,但前台可能一个都搜索不到!然后在后台找了下,发现两个所使用的搜索代码是不一样的!请问如何才能让前台使用后台的搜索代码!或者就是把前台的搜索代码改成和后台一样的搜索代码!麻烦大家给看看吧!我就是一小学教师!实在看不懂这些!先谢谢啦!
前台搜索代码:
<!--$include file="header.html"-->
<div class="leftshad"><div class="rightshad">
<div class="globalBox">
<div class="globalMain">
<div id="positionBody">
<div class="crumb"><span class="crumbleft"><b>当前位置:</b><a href="{$InstallDir}">{$tag:sitename}</a> → 搜索:{$newasp:keyword}</span></div>
<div style="clear:both"></div>
</div>
<div class="searchForm">
<div id="indexSearch">
<form name="searchform2" method="get" action="search.asp">
<input name="word" id="words" size="50" value="{$newasp:keyword}" maxlength='60' onFocus='this.select();' />
<select name="ChannelID" id="ChannelOption" class="alingmid">
<option value="1">请选择频道</option>
<option value="1">论文</option>
<option value="2">课件</option>
<option value="11">试卷</option>
<option value="12">教案</option>
<option value="19">素材</option>
<option value="20">教学参考</option>
<option value="13">教学软件</option>
<option value="18">中考高考</option>
<option value="16">天下教育</option>
<option value="17">计划总结</option>
</select>
<input name="searchbtn2" type="submit" value="开始搜索" />
</form>
</div>
</div>
<div id="searchmain">
<div class="searchResult">本次搜索共找到约 <span style="color:red">{$newasp:totalrec}</span> 条相关记录,<span style="color:red">{$newasp:keyword}</span> 结果如下</div>
{$topiclist:begin}
<div class="searchTopic">{$topiclist:i+}、<a href="{$topiclist:link}">{$topiclist:topic}</a></div>
<div class="searchIntro">{$topiclist:content}</div>
<div class="searchInfo"><span style="float:right">类别:{$topiclist:classtitle} 大小:{$topiclist:size} 日期:{$topiclist:date} [<a href="{$topiclist:link}" target="_blank">查看详细</a>]</span></div>
{$topiclist:end}
</div>
<div class="mainPageBox" id="NextPageText"><p class="list_page">{$xml:datalist id="showpage" file="page.xslt" type="1" max="10" title="显示分页"}</p></div>
</div><!-- End globalMain -->
</div>
</div></div>
<!--$include file="footer.html"-->
后台搜索代码
<!--#include file="const.asp"-->
<!--#include file="../../inc/cls_keyword.asp"-->
<%
Admin_header
'=====================================================================
' 软件名称:新云网站管理系统
' 当前版本:NewAsp Content Management System Version 4.0
' 文件名称:admin_search.asp
' 更新日期:2008-06-16
' 官方网站:新云网络(www. www.) QQ:94022511
'=====================================================================
' Copyright 2003-2008 - All Rights Reserved.
' newasp is a trademark of
'=====================================================================
Dim maxperpage,totalrec,Pcount,pagelinks,pagenow
Dim classid,SQLQuery,SQLField,searchTopic,searchmode,searchfield,fieldName
Dim ChildData,ischild,childstr,Keyword,searchMaxResult,ArryWords()
Keyword = Trim(Request("word"))
searchmode = NewAsp.ChkNumeric(Request("searchmode"))
searchfield = NewAsp.ChkNumeric(Request("searchfield"))
searchMaxResult = 1000
%>
<table class="table1" cellspacing="1" cellpadding="3" align="center" border="0">
<tr>
<td class="tableline"><form name="search_form" id="search_form" method="get" action="admin_search.asp">
<input type="hidden" name="ChannelID" value="<%=ChannelID%>">
<input type="text" class="alingmid" id="word" name="word" size="45" onfocus="if(this.value=='请输入关键字')this.value=''" value="<%=Server.HTMLEncode(Keyword)%>" />
<select name="searchfield" class="alingmid">
<option value="0">标题</option>
<option value="1"<%If searchfield=1 Then Response.Write " selected=""selected"""%>>录入者</option>
<option value="2"<%If searchfield=2 Then Response.Write " selected=""selected"""%>>版本</option>
<option value="3"<%If searchfield=3 Then Response.Write " selected=""selected"""%>>主页</option>
<option value="9"<%If searchfield=9 Then Response.Write " selected=""selected"""%>>标签</option>
</select>
<input type="submit" value="开始搜索" name="search_submit" class="button alingmid" />
<input type="checkbox" id="searchmode" name="searchmode" value="1" class="alingmid"<%If searchmode=1 Then Response.Write " checked=""checked"""%> /><label for="searchmode">分词搜索</label>
</form>
</td>
<td class="tableline" id="searchInfo" align="right"> </td>
</tr>
</table>
<%
If Not ChkAdmin("List_"&ChannelID) Then
Call Transfer_error()
End If
If Len(Keyword)>1 Then
Call showmain()
End If
Admin_footer
NewAsp.PageEnd
Sub showmain()
Dim i,iCount,lCount,iIndex
maxperpage=30
iIndex = 0
pagenow=NewAsp.ChkNumeric(Request("page"))
If pagenow=0 Then pagenow=1
classid=NewAsp.ChkNumeric(Request("classid"))
If classid>0 Then
ChildData=NewAsp.GetChildData(ChannelID,classid,0)
childstr=ChildData(0)
ischild=CLng(ChildData(2))
End If
SQLField = "A.softid,A.ChannelID,A.classid,A.SpecialID,A.SoftName,A.SoftVer,A.ColorMode,A.FontMode,A.username,A.SoftTime,A.AllHits,A.isTop,A.isBest,A.isAccept,A.SoftSize,C.ClassName"
%>
<form name="selform" method="post" action="admin_setting.asp?ChannelID=<%=ChannelID%>">
<input type="hidden" name="action" value="batch">
<table id="tablehovered" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
<tr>
<th width="5%" noWrap="noWrap">选择</th>
<th width="57%"><%=NewAsp.ModuleName%>标题</th>
<th width="9%" noWrap="noWrap">管理操作</th>
<th width="8%" noWrap="noWrap">文件大小</th>
<th width="9%" noWrap="noWrap">用户&评论</th>
<th width="12%" noWrap="noWrap">整理日期</th>
</tr>
<tr>
<td class="tablerow1" colspan="6" align="left" id="showNextPage"> </td>
</tr>
<%
Call searchTopicList()
iCount=2:lCount=2
If IsArray(searchTopic) Then
For i=0 To Ubound(searchTopic,2)
If Not Response.IsClientConnected Then Response.End
If (i mod 2) = 0 Then
iCount=2:lCount=1
Else
iCount=1:lCount=2
End If
%>
<tr align="center">
<td class="tablerow<%=iCount%> hovered"><input type="checkbox" name="softid" value="<%=searchTopic(0,i)%>"/></td>
<td class="tablerow<%=iCount%> hovered" align="left">[<a href="admin_list.asp?ChannelID=<%=ChannelID%>&classid=<%=searchTopic(2,i)%>"><%=searchTopic(15,i)%></a>]
<a href="admin_list.asp?action=view&ChannelID=<%=ChannelID%>&softid=<%=searchTopic(0,i)%>"><%=HighlightWord(searchTopic(4,i)&" "&searchTopic(5,i))%></a>
<%
If searchTopic(11,i)>0 Then Response.Write "<font color=""red""><b>顶</b></font>"
If searchTopic(12,i)>0 Then Response.Write "<font color=""blue""><b>精</b></font>"
%>
</td>
<td class="tablerow<%=iCount%> hovered" noWrap="noWrap"><a href="admin_post.asp?action=edit&ChannelID=<%=ChannelID%>&softid=<%=searchTopic(0,i)%>">编辑</a> | <a href="admin_setting.asp?action=del&ChannelID=<%=ChannelID%>&softid=<%=searchTopic(0,i)%>" onclick="return confirm('<%=NewAsp.ModuleName%>删除后将不能恢复,您确定要删除吗?')">删除</a></td>
<td class="tablerow<%=iCount%> hovered" noWrap="noWrap" title="人气:<%=searchTopic(10,i)%>"><%=NewAsp.BytesToString(CLng(searchTopic(14,i))*1024)%></td>
<td class="tablerow<%=iCount%> hovered" noWrap="noWrap" title="点击查看用户评论"><a href="admin_comment.asp?ChannelID=<%=ChannelID%>&softid=<%=searchTopic(0,i)%>"><%=searchTopic(8,i)%></a></td>
<td class="tablerow<%=iCount%> hovered" noWrap="noWrap"><%=showDateTime(searchTopic(9,i),"yyyy-MM-dd")%></td>
</tr>
<%
Next
End If
searchTopic=Null
%>
<tr>
<td class="tablerow<%=lCount%>" colspan="6"><input class="button" type="button" name="chkall" value="全选" onClick="CheckAll(this.form)"><input class="button" type="button" name="chksel" value="反选" onClick="ContraSel(this.form)">
管理选项:
<select name="act">
<option value="0">请选择操作选项</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="生成HTML">生成HTML</option>
</select>
<input class="button" type="submit" name="submit_button1" value="执行操作" onclick="return confirm('您确定执行该操作吗?');">
<input class="button" type="submit" name="submit_button2" value="批量设置" onclick="document.selform.action.value='setting';">
<input class="button" type="submit" name="submit_button3" value="批量移动" onclick="document.selform.action.value='move';">
</td>
</tr>
<tr>
<td class="tablerow<%=iCount%>" align="right" colspan="6" id="NextPageText">
<var class="morePage"><%=showlistpage(pagenow,Pcount,maxperpage,totalrec,pagelinks)%></var></td>
</tr>
</table>
</form>
<script type="text/javascript">
document.getElementById("showNextPage").innerHTML = document.getElementById("NextPageText").innerHTML;
var searchEl=document.getElementById("searchInfo");
if(searchEl)
searchEl.innerHTML = "找到相关结果约<%=totalrec%>条,用时<%=FormatNumber((Timer()-startime),3, -1)%>秒";
</script>
<%
End Sub
Sub searchTopicList()
Dim Rs,SQL,i,iCount,ArryKeyword
totalrec=0
Select Case searchfield
Case 0:fieldName="A.SoftName+' '+A.SoftVer"
Case 1:fieldName="A.username"
Case 2:fieldName="A.SoftVer+A.subtitle"
Case 3:fieldName="A.HomePage"
Case 9:fieldName="A.Taglist"
Case Else
fieldName="A.SoftName+' '+A.SoftVer+A.subtitle"
End Select
pagelinks="admin_search.asp?channelid="&ChannelID&"&classid="&classid&"&word="&Keyword&"&searchmode="&searchmode&"&searchfield="&searchfield&"&"
If Len(Keyword)>1 Then
If searchmode=1 Then
iCount=0
SQLQuery=""
ArryKeyword = cmWords.ParseKeyword(Keyword)
For i = 0 To UBound(ArryKeyword)
If Len(ArryKeyword(i)) > 1 Then
ReDim Preserve ArryWords(iCount)
ArryWords(iCount)=ArryKeyword(i)
If iCount=0 Then
If IsSqlDataBase=1 Then
SQLQuery=""&fieldName&" like '%"&ArryKeyword(i)&"%'"
Else
SQLQuery="InStr(1,LCase("&fieldName&"),LCase('"&ArryKeyword(i)&"'),0)>0"
End If
Else
If IsSqlDataBase=1 Then
SQLQuery=SQLQuery & " Or "&fieldName&" like '%"&ArryKeyword(i)&"%'"
Else
SQLQuery=SQLQuery & " Or InStr(LCase("&fieldName&"),LCase('"&ArryKeyword(i)&"'))>0"
End If
End If
iCount=iCount+1
End If
Next
If iCount=0 Then SQLQuery="":ReDim Preserve ArryWords(0):ArryWords(0)=""
Else
If cmWords.CheckKeyword(Keyword) Then
If IsSqlDataBase=1 Then
SQLQuery = ""&fieldName&" like '%"&Keyword&"%'"
Else
SQLQuery = "InStr(LCase("&fieldName&"),LCase('"&Keyword&"'))>0"
End If
ReDim Preserve ArryWords(0):ArryWords(0)=Keyword
Else
SQLQuery="":ReDim Preserve ArryWords(0):ArryWords(0)=""
End If
End If
If Len(SQLQuery) >10 Then SQLQuery=" And ("&SQLQuery&")" Else SQLQuery=""
If classid>0 Then
If ischild>0 Then
SQLQuery=" And A.isAccept=1 And A.classid in (" & childstr & ") "&SQLQuery
Else
SQLQuery=" And A.isAccept=1 And A.classid="&classid&" "&SQLQuery
End If
Else
SQLQuery=" And A.isAccept=1 "&SQLQuery
End If
If Not IsObject(Conn) Then ConnectionDatabase
Set Rs=NewAsp.CreateAXObject("ADODB.Recordset")
SQL="SELECT TOP "&searchMaxResult&" "& SQLField &" FROM [NC_SoftList] A INNER JOIN [NC_Classify] C on A.ClassID=C.ClassID WHERE A.ChannelID=" &ChannelID& " "&SQLQuery&" ORDER BY A.SoftTime DESC"
Rs.Open SQL,Conn,1,1
If pagenow >1 Then
Rs.Move (pagenow-1) * maxperpage
End If
If Not Rs.EOF Then
totalrec = CLng(Rs.Recordcount) '###记录总数
searchTopic=Rs.GetRows(maxperpage)
Else
searchTopic=Null
End If
Rs.close()
Set Rs=Nothing
End If
Pcount = CLng(totalrec / maxperpage)
If Pcount < totalrec / maxperpage Then Pcount = Pcount + 1
If pagenow>Pcount Then pagenow=1
End Sub
Function HighlightWord(str)
Dim i
For i=0 To UBound(ArryWords)
If ArryWords(i)<>"" Then str=Replace(str, ArryWords(i), "<font color=""red"">"& ArryWords(i) &"</font>")
Next
HighlightWord=str
End Function
%>