Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Di nuovo sul motore di ricerca (help)

    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
    %>

  2. #2
    Ciao, ho risolto tutto....
    Solo che ora ho un altro problemino, sempre con SPLIT.
    Spero che qualcuno mi possa aiutare...In pratica in un campo del mio database vengono inseriti diversi LINK che fanno riferimento a delle immagini, separati da uno spazio.

    Ora io vorrei recuperarli e farli vedere sotto forma di immagini linkate. Ho provato così:

    codice:
    <%
    UID = Request("UID")
    
    dim conn
    set conn = Server.CreateObject("ADODB.Connection")
    conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("/mdb-database/mydb1.mdb")
    
    Dim Query, Rs
    Query = "select UID,Nickname,Screen1 from Profile where (UID = '" & UID & "')"
    Set Rs = Server.CreateObject("ADODB.Recordset")
    Rs.Open Query, Conn, 3, 3
    
    
    
    ArrSearch = Split(Screen1) 
    for each Img In ArrSearch
    Img = trim(Img)
    
    
    response.write "[img][/img]"
    response.write ""& Img &""
    Next
    
    
    Rs.Close
    set Rs = Nothing
    Conn.Close
    Set Conn= Nothing
    
    %>
    Ma non va! Non mi dice errore ma non mi fa neanche vedere nulla! Ho fatto un test e il campo Screen1 viene visualizzato con un response.write classico.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.