主题:网站搜索没有后台搜索精确!如何把前台搜索和后台搜索改成一样的!
后台搜索比较精确!经常会出现同一个关键字,后台可以搜索到几十个代码,但前台可能一个都搜索不到!然后在后台找了下,发现两个所使用的搜索代码是不一样的!请问如何才能让前台使用后台的搜索代码!或者就是把前台的搜索代码改成和后台一样的搜索代码!麻烦大家给看看吧!我就是一小学教师!实在看不懂这些!先谢谢啦!
前台搜索代码:
<!--$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.newasp.net www.newasp.cn) QQ:94022511
'=====================================================================
' Copyright 2003-2008 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
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">
因帖子限制,所以后台搜索部分代码放在回复里!
前台搜索代码:
<!--$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.newasp.net www.newasp.cn) QQ:94022511
'=====================================================================
' Copyright 2003-2008 newasp.net - All Rights Reserved.
' newasp is a trademark of newasp.net
'=====================================================================
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">
因帖子限制,所以后台搜索部分代码放在回复里!