In addition to the background, we usually set a "keyword", and the general input may be as follows:
Dolls, plush dolls, Japanese inflatable dolls
We will follow the steps below:
First look at an SQL statement:
CopyCode The Code is as follows: Select top 3 Sid, sname from product where keywords like '% doll %' or keywords like '% plush doll %' or keywords like '% Japanese inflatable doll %'
Based on this statement, we can find related products or related products.Article(In fact, there are more complex and better implementations, but this is not mentioned here), the following is the key code:Copy codeThe Code is as follows: <% @ Language = "VBScript" codePage = "65001" %>
<% Response. charset = "gb2312" %>
<%
Dim A: A = "doll, plush doll, Japanese inflatable doll"
'Obj is the value and filed is the field name.
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.exe cute (MySQL)
'Do while not objrs. EOF
'Response. Write (objrs ("sname "))
'Loop
'Objrs. Close
'Set objrs = nothing
'Objconn. Close
'Set objconn = nothing
%>