Visualizzazione dei risultati da 1 a 7 su 7

Discussione: ricerca

  1. #1
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    589

    ricerca

    come faccio usando like o altro a cercare una o piu parole parole contenute in un campo con piu parole


    codice asp

    cerca = " where nomearticolo like '" & cerca & "%'order by data desc" :master:

  2. #2
    codice:
    ricerca = request.form("ricerca")
    voci = split(ricerca)
    sql = "SELECT * FROM tabella WHERE"
    for i = 0 to uBound(voci)
    sql = sql & " campo LIKE '%" & voci(i) & "%'"
    if i < uBound(voci) then sql = sql & " OR"
    next
    response.write sql

  3. #3
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    589
    vedendola riga di codice mia , sostituisco poi cerca con sql no?

  4. #4
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    589
    questo è il codice non so come modificarlo col tuo

    <% dim cerca, pp
    'estrazione della pagina corrente

    pag=trim(request("pag"))
    cerca=replace(Trim(request("cerca")),"'", "")
    pp=cerca


    if pag="" then pag=1
    if IsEmpty(Request.querystring("cerca")) then
    cerca = " where nomearticolo like '" & Request.querystring("cerca") & "%'order by data desc "

    strricerca = "select * from richieste"

    else



    if Request.querystring("cerca")<>"" then
    cerca = " where nomearticolo like '" & cerca & "%'order by data desc"


    else
    cerca = " where nomearticolo like '%' order by data desc"
    end if





    strricerca = "select * from richieste " & cerca

    end if

    'Response.Write strricerca
    'Response.End
    set rsestrai=Server.CreateObject("adodb.recordset")
    rsestrai.LockType=3
    rsestrai.CursorType=3
    rsestrai.PageSize=5
    rsestrai.ActiveConnection=connessione
    rsestrai.Open strricerca



    %>

  5. #5
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    589
    guarda ho provato io e funziona , lunica cosa e che avendo per esempio campi come "lupo alberto" "lupo dario"

    immettendo in cerca lupo dario mi fa comparire anche lupo alberto, cmq va bene anche cosi grazie


    <%
    ' dim rsestrai, zona, tipologia, immobile, mq, importo
    ' dim strricerca, pag, i, rowcount, cerca, pp
    dim cerca, pp, sql
    'estrazione della pagina corrente

    pag=trim(request("pag"))
    cerca=replace(Trim(request("cerca")),"'", "")
    pp=cerca


    if pag="" then pag=1
    if IsEmpty(Request.querystring("cerca")) then
    cerca = " where nomearticolo like '" & Request.querystring("cerca") & "%'order by data desc "

    sql = "select * from richieste"








    else



    if Request.querystring("cerca")<>"" then
    ' cerca = " where nomearticolo like '" & cerca & "%'order by data desc"

    voci = split(cerca, " ")
    sql = "SELECT * FROM richieste WHERE"
    for i = 0 to ubound(voci)
    sql = sql & " nomearticolo LIKE '%" & voci(i) & "%'"
    if i < ubound(voci) then sql = sql & " OR"
    next



    else
    cerca = " where nomearticolo like '%' order by data desc"

    sql = "select * from richieste " & cerca
    end if







    end if

    'Response.Write strricerca
    'Response.End
    set rsestrai=Server.CreateObject("adodb.recordset")
    rsestrai.LockType=3
    rsestrai.CursorType=3
    rsestrai.PageSize=5
    rsestrai.ActiveConnection=connessione
    rsestrai.Open sql



    %>




  6. #6
    prova a sostituire OR con AND

  7. #7
    Utente di HTML.it
    Registrato dal
    Sep 2001
    Messaggi
    589
    grande

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.