Question about separating phrases by spaces in ASP search

Source: Internet
Author: User

For example, when searching, the two phrases are opened with an empty lattice. How can I modify the code below to search for them? Is it ASP + SQL? Attach your own code to consult the experts:
<%
Sub search
Ypxxone_id = request ("ypxxone_id ")
Ypxxtwo_id = request ("ypxxtwo_id ")
Addone_id = request ("addone_id ")
Addtwo_id = request ("addtwo_id ")
WORD = request ("word ")
If word = "" then
Response. Redirect "../"
End if
Key = request ("key ")
Response. Redirect "Search _" & Key & ". asp? WORD = "& escape (word) & "& Key =" & Key & "& ypxxone_id =" & ypxxone_id & "& ypxxtwo_id =" & ypxxtwo_id & "& addone_id =" & addone_id & "& addtwo_id = "&""
End sub

If userflag16 = 1 then
Search
Else
Response. Write smt_user_flagerr
End if
%>

<% SQL = "select * From smt_yp where smt_key <> 0 and smt_key <> 2 and smt_key <> 4 and smt_key1 = 1 and (smt_coname like '%" & word & "% 'or smt_cojc like' % "& word &" % 'or smt_coms like' % "& word &" % ') "& xxsort & addsort &" order by smt_id DESC"
Set rs = server. Createobject ("ADODB. recordset ")
Rs. Open SQL, Conn, 1, 1
If Rs. EOF and Rs. bof then
Response. write "<tr> <TD Height = 50> NO content matching" <font color = Red> "& word &" </font> "is found, try another search. </TD> </tr>"
Else
'Paging implementation
Listnum = 10
Rs. pagesize = listnum
Page = request ("page ")
If (page-Rs.pagecount)> 0 then
Page = Rs. pagecount
Elseif page = "" or page <1 then
Page = 1
End if
Rs. absolutepage = page
'Number implementation
J = Rs. recordcount
J = J-(page-1) * listnum
I = 0
Do while not Rs. EOF and I <listnum
Goname = RS ("smt_user ")
GoId = RS ("smt_id ")
'================================
Smt_coname = Replace (RS ("smt_coname"), "<font color = Red>" & word & "</font> ")
AAA = trim (RS ("smt_coms "))
If instr (AAA, word) then
A = Len (AAA)
B = instr (AAA, word)
If B <50 then c = left (AAA, B) else c = "..." & Mid (AAA, B-50, 50)
If a-(B + Len (Word) <50 then D = right (AAA, A-(B + Len (Word) else d = mid (AAA, B, 50 )&"..."
Smt_coms = C & D
Else
Smt_coms = trim (left (AAA, 100 ))&"..."
End if
Smt_coms = Replace (smt_coms, "<font color = Red>" & word & "</font> ")
'================================
%>

Scores will be added if the problem can be solved!

Question added:The code above shows that only words can be connected to words for search, such as "Beijing Palace Museum", but like "Beijing Palace Museum ", no space is found in the middle .....
I hope to modify the code according to me. I am not very familiar with this, so I hope to follow the details of my code as much as possible. Thank you for your consideration.

Best Answer

Example
-----

Key = Split (keyword, "") 'splits the passed keywords into arrays by Space

'Traverse the array and create a like sentence for each keyword to connect with or

Ssql = "1 <> 1"
For II = 0 to ubound (key)
If trim (Key (II) <> "then
Ssql = "or ziduan like '%" & Key (ii) & "% '"
End if
Next

SQL = SQL & "and (" & ssql &")"
'Remember to use parentheses here. Otherwise, an error will occur ..

--------------------------------

A rough idea, specific research on your own ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.