Ecco il codice:
<%
Dim orderBy
orderBy = request.querystring("orderby")
dim SQL
dim SearchFor
dim SearchWhere
SearchWhere = request("SearchWhere")
SearchFor = request("SearchFor")
dim SQL_SearchFor
dim SQL_SearchWhere
If (SearchWhere = "All") Then
SQL_SearchWhere = "(List_ID LIKE ('%" & SearchFor & "%') OR Name_First LIKE ('%" & SearchFor & "%') OR CAP LIKE ('%" & SearchFor & "%') OR Name_Last LIKE ('%" & SearchFor & "%') OR statoOprovincia LIKE ('%" & SearchFor & "%') OR password LIKE ('%" & SearchFor & "%') OR regioni_Name LIKE ('%" & SearchFor & "%') OR nazioni_Name LIKE ('%" & SearchFor & "%'))"
Else
SQL_SearchWhere = SearchWhere & " LIKE ('%" & SearchFor & "%')"
End If
If NOT (SearchFor = "") Then
SQL_SearchFor = " WHERE " & SQL_SearchWhere
Else
SQL_SearchFor = ""
End If
If orderBy = "name_first_down" Then
SQL_OrderBy = " ORDER BY name_first DESC"
ElseIf orderBy = "Date_In_Up" Then
SQL_OrderBy = " ORDER BY date_In"
ElseIf orderBy = "Date_In_Down" Then
SQL_OrderBy = " ORDER BY date_In DESC"
ElseIf orderBy = "nomecategoria_Up" Then
SQL_OrderBy = " ORDER BY newsletter_name"
ElseIf orderBy = "nomecategoria_Down" Then
SQL_OrderBy = " ORDER BY newsletter_name DESC"
'ElseIf orderBy = "nomecategoria_Up" Then
'SQL_OrderBy = " ORDER BY nomecategoria"
Else
orderBy = "name_first_up"
SQL_OrderBy = " ORDER BY name_first"
End If
SQL = "SELECT * FROM listquery" & SQL_SearchFor & SQL_OrderBy
'%>
Sarò sincero, questo script l'ho trovato... quando faccio le ricerce, non cerca mai valori esatti ma sempre parziali. Esempio via= via - viale - vialetto. Per gli indirizzi non è un problema ma per il codice cliente si.
La corretta sintassi di interrogazione che compare sulla barra indirizzo è:
www.miositosubscribers.asp?searchfor=3& ... re=List_Id
E' possibile fare una ricerca nella query ed avere solo i risultati che siano uguali al testo indicato nella ricerca