ASP 相關(guān)文章或者相關(guān)產(chǎn)品
更新時(shí)間:2009年05月29日 20:28:15 作者:
以下僅提供相關(guān)思路和關(guān)鍵代碼,并且只提供一種最簡(jiǎn)單的算法實(shí)現(xiàn),稍復(fù)雜的本文不做介紹。
在后臺(tái)添加中一般我們都設(shè)置了一個(gè)“關(guān)鍵字”,而且一般輸入可能如下:
娃娃,毛絨娃娃,日本充氣娃娃
我們將根據(jù)這個(gè)來(lái)做,具體實(shí)現(xiàn)如下:
先看一條SQL語(yǔ)句:
select top 3 sid,sname from product where keywords like '%娃娃%' or keywords like '%毛絨娃娃%' or keywords like '%日本充氣娃娃%'
那么我們根據(jù)這條語(yǔ)句就可以搜索到相關(guān)產(chǎn)品或者相關(guān)文章了(其實(shí)有更復(fù)雜以及更好的實(shí)現(xiàn),但這里暫時(shí)不提及了),以下是關(guān)鍵代碼:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.Charset="gb2312" %>
<%
Dim A:A = "娃娃,毛絨娃娃,日本充氣娃娃"
'obj為值,filed為字段名
Function sqlKeyWord(obj,field)
Dim temp:temp = split(obj,",")
For i = 0 To ubound(temp)
sqlKeyWord = sqlKeyWord & field&" like '%"&temp(i)&"%' or "
Next
sqlKeyWord = left(sqlKeyWord,len(sqlKeyWord)-3)
End Function
Dim mysql:mysql = "select top 3 sid,sname from product where " + sqlKeyWord(A,"keywords")
Response.Write(mysql)
'Set objRs = objConn.execute(mysql)
'Do while not objRs.Eof
'Response.Write(objRs("sname"))
'Loop
'objRs.close
'set objRs = nothing
'objConn.close
'set objConn = nothing
%>
娃娃,毛絨娃娃,日本充氣娃娃
我們將根據(jù)這個(gè)來(lái)做,具體實(shí)現(xiàn)如下:
先看一條SQL語(yǔ)句:
復(fù)制代碼 代碼如下:
select top 3 sid,sname from product where keywords like '%娃娃%' or keywords like '%毛絨娃娃%' or keywords like '%日本充氣娃娃%'
那么我們根據(jù)這條語(yǔ)句就可以搜索到相關(guān)產(chǎn)品或者相關(guān)文章了(其實(shí)有更復(fù)雜以及更好的實(shí)現(xiàn),但這里暫時(shí)不提及了),以下是關(guān)鍵代碼:
復(fù)制代碼 代碼如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Response.Charset="gb2312" %>
<%
Dim A:A = "娃娃,毛絨娃娃,日本充氣娃娃"
'obj為值,filed為字段名
Function sqlKeyWord(obj,field)
Dim temp:temp = split(obj,",")
For i = 0 To ubound(temp)
sqlKeyWord = sqlKeyWord & field&" like '%"&temp(i)&"%' or "
Next
sqlKeyWord = left(sqlKeyWord,len(sqlKeyWord)-3)
End Function
Dim mysql:mysql = "select top 3 sid,sname from product where " + sqlKeyWord(A,"keywords")
Response.Write(mysql)
'Set objRs = objConn.execute(mysql)
'Do while not objRs.Eof
'Response.Write(objRs("sname"))
'Loop
'objRs.close
'set objRs = nothing
'objConn.close
'set objConn = nothing
%>
相關(guān)文章
響應(yīng)對(duì)象 錯(cuò)誤 ''ASP 0185 : 80020003'' 缺少默認(rèn)屬性
發(fā)現(xiàn)個(gè)垃圾后臺(tái)用了大量的Response.Cookies,導(dǎo)致后臺(tái)認(rèn)證出錯(cuò)。2007-12-12
ASP開(kāi)發(fā)中數(shù)據(jù)庫(kù)文件調(diào)用的捷徑
本文針對(duì)ASP程序設(shè)計(jì)中最基礎(chǔ)、也是最關(guān)鍵的部分"數(shù)據(jù)庫(kù)文件的調(diào)用"進(jìn)行說(shuō)明,同時(shí)談?wù)凙SP程序設(shè)計(jì)中數(shù)據(jù)庫(kù)文件調(diào)用的一些技巧2006-09-09
PJ-Blog教程┊增強(qiáng)博客用戶體驗(yàn)~讓發(fā)表內(nèi)容的同時(shí)拷貝到剪貼板以防丟失
PJ-Blog教程┊增強(qiáng)博客用戶體驗(yàn)~讓發(fā)表內(nèi)容的同時(shí)拷貝到剪貼板以防丟失...2007-01-01
Microsoft JET Database Engine(0x80004005)未指定錯(cuò)誤的解決方法
今天在配置iis asp運(yùn)行環(huán)境的時(shí)候提示Microsoft JET Database Engine(0x80004005)未指定錯(cuò)誤,不過(guò)最后通過(guò)如下方法解決了,這里腳本之家小編特為大家分享下,方便需要的朋友2014-06-06
ASP 關(guān)于動(dòng)態(tài)數(shù)據(jù)顯示頁(yè)面得錨點(diǎn)
ASP 關(guān)于動(dòng)態(tài)數(shù)據(jù)顯示頁(yè)面得錨點(diǎn)...2007-09-09

