Ciao, sempre in base al codice che aveva riportato Mems sto tentando di creare una ricerca che vada ad analizzare DUE campi del database dopo che l'utente ha compilato UN SOLO input in un form. Ma non funziona, effettua la ricerca solo su "nowcar".
Inoltre volevo fare che sul secondo campo del database (pastcar) che è composto da più parole chiave separate da uno spazio, si possa effetuare una ricerca sulle singole parole...
Pensavo di usare questo controllo:
ArrSearch = Split(parole) ‘divide la stringa nelle singole parole-chiave
x = 0
for each word In ArrSearch
word = trim(word)
sql = sql & " campo1 like '%" & word & "%'"
End If
Ma come integrarlo?
Vi prego aiutatemi!
Riporto il codice
codice:<% esegui = false risultatiPerPagina = 10 pagina = request.queryString("pagina") if len(pagina) > 0 and isNumeric(pagina) then pagina = cLng(pagina) else pagina = 1 end if if pagina < 1 then pagina = 1 questaPagina = request.serverVariables("PATH_INFO") nowcar = request.queryString("nowcar") pastcar = request.queryString("pastcar") qString = "nowcar =" & server.URLEncode(nowcar) & "&pastcar=" & server.URLEncode(pastcar) function fixSQL(theString) theString = replace(theString,"'","''") theString = replace(theString,"%","[%]") theString = replace(theString,"#","[#]") theString = replace(theString,"_","[_]") theString = replace(theString,"[","[[]") theString = replace(theString,"]","[]]") fixSQL = theString end function sql = "SELECT * FROM Profile WHERE 1 = 1 " if len(nowcar) > 0 then esegui = true sql = sql & "AND [nowcar] like '" & fixSQL(nowcar) & "' " end if if len(pastcar) > 0 then esegui = true sql = sql & "AND [pastcar] like '" & fixSQL(pastcar) & "' " end if sql = sql & "ORDER BY [ID]" if esegui then Set adoCon = Server.CreateObject("ADODB.Connection") strDataBasePath = "mdb-database/db1.mdb" cString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strDataBasePath) adoCon.Open cString set rs = server.createObject("ADODB.Recordset") rs.open sql, adoCon, 3, 1 if not rs.eof then rs.pageSize = risultatiPerPagina rs.absolutePage = pagina response.write "<center>" response.write " " response.write "<font face=""Arial"" Size=""3"">Total Results: " & rs.recordCount response.write "</font>" response.write " <font face=""Arial"" Size=""3"">Page: " for p = 1 to rs.pageCount if p = pagina then response.write p & " " response.write "</font>" else response.write "" & p & " " end if next for r = 1 to risultatiPerPagina if not rs.eof then response.write "<table border=""1"" cellpadding=""5"" width=""600"" bordercolordark=""#FFFFFF"" bordercolorlight=""#FFFFFF"" bgcolor=""#000080"" height=""40"">" response.write "<tr><td align=""center"" height=""19"" bgcolor=""#000000"" bordercolor=""#00FFFF"" width=""100""><p align=""center""><font color=""#FFFFFF"" face=""Arial"">" & Rs("Nickname") & "</p></font></td>" response.write "<td height=""19"" bgcolor=""#99CCFF"" bordercolor=""#00FFFF"" width=""100"">" response.write "<p align=""center""><font face=""Arial"" color=""#000000"">" & Rs("Country") & "</font></td>" response.write "<td height=""19"" bgcolor=""#000000"" bordercolor=""#00FFFF"" width=""100"">" response.write "<p align=""center""><font color=""#FFFFFF"" face=""Arial"">" & Rs("City") & "</font></td>" response.write "<td height=""19"" bgcolor=""#99CCFF"" bordercolor=""#00FFFF"" width=""100"">" response.write "<p align=""center""><font face=""Arial"" color=""#000000"">" & Rs("Gender") & "</font></td>" response.write "<td height=""19"" bgcolor=""#000000"" bordercolor=""#00FFFF"" width=""100"">" response.write "<p align=""center""><font color=""#FFFFFFF"" face=""Arial"">" & Rs("Age") & "</font></td>" response.write "<td height=""19"" bgcolor=""#99CCFF"" bordercolor=""#00FFFF"" width=""100"">" response.write "</tr>" rs.moveNext response.write "</table>" else exit for end if next response.write "<font face=""Arial"" Size=""3"">Page: " for p = 1 to rs.pageCount if p = pagina then response.write p & " " else response.write "" & p & " " end if next else response.write "<p align=""center""><font face=""Arial"" Size=""3"">No results found. Try Again.</font></p>" end if rs.close set rs = nothing adoCon.close set adoCon = nothing else response.write "<p align=""center""><font face=""Arial"" Size=""3"">Insert one Car!</font></p>" end if %>

Rispondi quotando