Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Search for multiple words
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Forum LockedSearch for multiple words

 Post Reply Post Reply
Author
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 277
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post Topic: Search for multiple words
    Posted: 15 December 2010 at 6:59pm
 I have this code to search for multiple words, but do not work me in Web Wiz NewsPad. This same code I have a website and it works perfectly. I have a lookup field as having the Forum.
Sorry for my English. I'm translating from the Spanish. Thank you.
 
 
pbuscar = Request.querystring("KW")
arr = split(pbuscar,"+")
for i = 0 to ubound(arr)
palabra=arr(i)
if i <> 0 then
strSQL = strSQL & " or "
end if
strSQL = strSQL & "(" & strDbTable & "Newsletter.Newsletter_subject Like '%" & palabra & "%' OR " & strDbTable & "Newsletter.Description Like '%" & palabra & "%')"
next
strSQL = strSQL & "ORDER BY " & strDbTable & "Newsletter.Newsletter_date DESC;"
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 16 December 2010 at 8:31am
The first thing is that you have no sanitisation and so the code leaves you wise open to SQL Injection attacks that can be used to either manipulate the database or worse still inject malware in to your website which would get you blacklisted from Google.
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 277
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post Posted: 16 December 2010 at 8:41am
Is there a way to create a lookup field and find multiple words in a search as Web Wiz Forums? Thank you.
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat
Back to Top
123Simples View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 July 2007
Location: United Kingdom
Status: Offline
Points: 1192
Post Options Post Options   Thanks (0) Thanks(0)   Quote 123Simples Quote  Post ReplyReply Direct Link To This Post Posted: 16 December 2010 at 12:24pm
When you do a search on Web Wiz forums, there is an option saying Advanced Search
Click that and you can match ALL words or match ANY words, phrase etc
You would need to compare files between the two types of software to probably find a way to enable this type of search in newspad - it would be probably quite a complex task
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 277
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post Posted: 21 December 2010 at 5:36pm
In the following message attachment code I created and work me well. Will I have a problem with SQL?


Edited by Roberto Randall - 28 December 2010 at 9:06am
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat
Back to Top
Roberto Randall View Drop Down
Senior Member
Senior Member
Avatar

Joined: 21 August 2009
Location: San Pedro Alc.
Status: Offline
Points: 277
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roberto Randall Quote  Post ReplyReply Direct Link To This Post Posted: 25 December 2010 at 10:26pm
I leave this code I have to search for words and highlight those found. To me me works well and let it to whom you want to use. The code can be improved, but I get to here:
 
 
 
page_layout_footer_inc.asp
 
 
            <select name="SR" id="SR">
              <option value="todas">Buscar todas las palabras</option>
              <option value="cualquiera">Buscar cualquier palabra</option>
              <option value="frase">Buscar frase</option>
            </select>
 
 
functions_common.asp
 
 
'******************************************
'***     Reemplaza los acentos para realizar la búsqueda   ***
'******************************************
Function acentocuent(strcuent)
 strcuent = Replace(strcuent, "\'", "&#092;'", 1, -1, 1)
 strcuent = Replace(strcuent, """", "", 1, -1, 1)
 strcuent = Replace(strcuent, "'", "''", 1, -1, 1)
 strcuent = Replace(strcuent, "[", "&#091;", 1, -1, 1)
 strcuent = Replace(strcuent, "]", "&#093;", 1, -1, 1)
 strcuent = Replace(strcuent, "<", "&lt;", 1, -1, 1)
 strcuent = Replace(strcuent, ">", "&gt;", 1, -1, 1)
 strcuent = replace(strcuent,"Á","A")
 strcuent = replace(strcuent,"á","a")
 strcuent = replace(strcuent,"à","a")
 strcuent = replace(strcuent,"â","a")
 strcuent = replace(strcuent,"ä","a")
 strcuent = replace(strcuent,"ã","a")
 strcuent = replace(strcuent,"a","[a,á,à,ã,â,ä]")
 strcuent = replace(strcuent,"É","E")
 strcuent = replace(strcuent,"é","e")
 strcuent = replace(strcuent,"è","e")
 strcuent = replace(strcuent,"ê","e")
 strcuent = replace(strcuent,"ë","e")
 strcuent = replace(strcuent,"e","[e,é,è,ê,ë]")
 strcuent = replace(strcuent,"Í","I")
 strcuent = replace(strcuent,"í","i")
 strcuent = replace(strcuent,"í","i")
 strcuent = replace(strcuent,"î","i")
 strcuent = replace(strcuent,"ï","i")
 strcuent = replace(strcuent,"i","[i,í,ì,î,ï]")
 strcuent = replace(strcuent,"Ó","O")
 strcuent = replace(strcuent,"ó","o")
 strcuent = replace(strcuent,"ò","o")
 strcuent = replace(strcuent,"ô","o")
 strcuent = replace(strcuent,"ö","o")
 strcuent = replace(strcuent,"õ","o")
 strcuent = replace(strcuent,"o","[o,ó,ò,ô,õ,ö]")
 strcuent = replace(strcuent,"Ú","U")
 strcuent = replace(strcuent,"ú","u")
 strcuent = replace(strcuent,"ù","u")
 strcuent = replace(strcuent,"û","u")
 strcuent = replace(strcuent,"ü","u")
 strcuent = replace(strcuent,"u","[u,ú,ù,û,ü]")
 
 strcuent = replace(strcuent," ","+")
 acentocuent = strcuent
End Function
 
 

'******************************************
'***     Reemplaza los acentos para realizar la búsqueda   ***
'******************************************
Function acento(stracentudado)
 stracentudado = Replace(stracentudado, "\'", "&#092;'", 1, -1, 1)
 stracentudado = Replace(stracentudado, """", "", 1, -1, 1)
 stracentudado = Replace(stracentudado, "'", "''", 1, -1, 1)
 stracentudado = Replace(stracentudado, "[", "&#091;", 1, -1, 1)
 stracentudado = Replace(stracentudado, "]", "&#093;", 1, -1, 1)
 stracentudado = Replace(stracentudado, "<", "&lt;", 1, -1, 1)
 stracentudado = Replace(stracentudado, ">", "&gt;", 1, -1, 1)
 stracentudado = replace(stracentudado,"Á","A")
 stracentudado = replace(stracentudado,"á","a")
 stracentudado = replace(stracentudado,"à","a")
 stracentudado = replace(stracentudado,"â","a")
 stracentudado = replace(stracentudado,"ä","a")
 stracentudado = replace(stracentudado,"ã","a")
 stracentudado = replace(stracentudado,"a","[a,á,à,ã,â,ä]")
 stracentudado = replace(stracentudado,"É","E")
 stracentudado = replace(stracentudado,"é","e")
 stracentudado = replace(stracentudado,"è","e")
 stracentudado = replace(stracentudado,"ê","e")
 stracentudado = replace(stracentudado,"ë","e")
 stracentudado = replace(stracentudado,"e","[e,é,è,ê,ë]")
 stracentudado = replace(stracentudado,"Í","I")
 stracentudado = replace(stracentudado,"í","i")
 stracentudado = replace(stracentudado,"í","i")
 stracentudado = replace(stracentudado,"î","i")
 stracentudado = replace(stracentudado,"ï","i")
 stracentudado = replace(stracentudado,"i","[i,í,ì,î,ï]")
 stracentudado = replace(stracentudado,"Ó","O")
 stracentudado = replace(stracentudado,"ó","o")
 stracentudado = replace(stracentudado,"ò","o")
 stracentudado = replace(stracentudado,"ô","o")
 stracentudado = replace(stracentudado,"ö","o")
 stracentudado = replace(stracentudado,"õ","o")
 stracentudado = replace(stracentudado,"o","[o,ó,ò,ô,õ,ö]")
 stracentudado = replace(stracentudado,"Ú","U")
 stracentudado = replace(stracentudado,"ú","u")
 stracentudado = replace(stracentudado,"ù","u")
 stracentudado = replace(stracentudado,"û","u")
 stracentudado = replace(stracentudado,"ü","u")
 stracentudado = replace(stracentudado,"u","[u,ú,ù,û,ü]")
 
 acento = stracentudado
End Function
 
 
 
default.asp
 
 
Dim strSearchphrase  'Holds the search phrase
Dim arr
Dim palabra
Dim stroperador
Dim strphrase
Dim buscando
Dim cuent
Dim texto
Dim strnoticia
Dim luz
Dim texto_split

'Get the search critiria if this is a search (clean it up incase of SQL injection
If NOT Request.QueryString("KW") = "" Then
 strSearchCriteria = acentocuent(Trim(Request.QueryString("KW")))
 strSearchphrase = acento(Trim(Request.QueryString("KW")))
End If

arr = split(Trim(strSearchCriteria),"+")
texto = Request.QueryString("KW")
texto_split = split(Trim(texto), " ")

'Read in form input
stroperador = Request.QueryString("SR")
strphrase = Request.QueryString("SR")

'If this is a search for All Words use 'AND' for SQL
If stroperador = "todas" Then
 stroperador = "And"
'Else if this is a search of Any Words use 'OR' for the SQL
Else
 stroperador = "Or"
End If
 
 
 
 
 
'If a search cretiria is selected then run a where like query
If strSearchCriteria <> "" AND strphrase = "frase" Then
 strSQL = strSQL & "(" & strDbTable & "Newsletter.Newsletter_subject Like '%" & strSearchphrase & "%' OR " & strDbTable & "Newsletter.Description Like '%" & strSearchphrase & "%')"
ElseIf strSearc
https://www.lanocion.es - https://www.lanocion.games - https://www.lanocion.chat
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.