Salve, con tanta fatica sono riuscito a mettere insieme un motore di ricerca abbastanza completo, con una "semplice" paginazione dei risultati. Fin qui tutto ok, però c'è il solito problema... ossia non riesco a fargli avanzare di pagina o meglio all'avanzamento di pagina, la seconda appare priva di risultati.
Vi posto il codice ripulito della grafica e fronzoli vari non importanti alla risoluzione del problema, ma vi anticipo che non sono molto esperto in ASP, tuttavia mi piace smanettare (in ASP intendo, eh!)
Anche la struttura è da sistemare, ma prima volevo risolvere questo problema.
Ormai sono giorni che mi sbatto ma non sono riuscito a trovare una soluzione.
Codice PHP:
<FORM action="default2.asp?Azione=RICERCA" method=post name=form1>
<font face="Verdana" size="2">Cerca:</font><INPUT name=Parole size=40>
<INPUT type="submit" value="Cerca" name=submit1></font>
Tipo di ricerca: <SELECT name=Tiporicerca>
<OPTION value=PARTE selected>Almeno una parola presente</OPTION>
<OPTION checked value=TUTTE>Tutte le parole presenti</OPTION>
</SELECT>
Ricerca in questa categoria: <SELECT name=Genere>
<OPTION VALUE=NULLO checked selected>------------------</OPTION>
<OPTION value=Agricoltura>Agricoltura</OPTION> <OPTION value=Amministrazione>Amministrazione</OPTION>
<OPTION value=Animali>Animali</OPTION> <OPTION value=Archeologia>Archeologia</OPTION>
<OPTION value=Architettura>Architettura</OPTION></SELECT>
Ordina per:<SELECT name=Ordine>
<OPTION CHECKED VALUE=Data selected>Data</OPTION>
<OPTION VALUE=titolo_libro>Titolo</OPTION>
<OPTION VALUE=Genere>Genere</OPTION>
<option value="Visite">Visite</option>
<option value="Autore">Autore</option>
<option value="Prezzo">Prezzo</option>
</SELECT></font></td>
</FORM>
<p style="margin-top: 10; margin-left: 10">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="100%">
<%
Dim conn,iPageSize,iPageCount,iPageCurrent,strOrderBy,RS,iRecordsShown
iPageSize = 10
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If
Dim Azione, Parole
Azione = Request.QueryString ("Azione")
IF Azione = "RICERCA" THEN
strSQL = "SELECT ID, titolo_libro, Autore, descrizione_libro, keyword, Data, email, url_sito, url_immagine, Prezzo, clicks, clickunici, Genere FROM Libri "
Parole = Trim(Request.Form ("Parole"))
Tiporicerca = Request.Form("Tiporicerca")
Genere = Request.Form ("Genere")
Ordine = Request.Form ("Ordine")
Dim arrayParole, Legame, Istringa,IIstringa, IIIstringa, Genere
Dim Ordine, Tiporicerca, strSQL
arrayParole=split(Parole," ",3)
If Parole <> "" then
If Tiporicerca = "TUTTE" then
Legame = " AND "
Else
Legame = " OR "
End if
Istringa = "(keyword LIKE '%" & arrayParole(0) & "%' OR titolo_libro LIKE '%" & arrayParole(0) & "%' OR descrizione_libro LIKE '%" & arrayParole(0) & "%' OR Autore LIKE '%" & arrayParole(0) & "%'"
'Istringa = "(keyword LIKE '%" & arrayParole(0) & "%'"
'Istringa = "(titolo_libro LIKE '%" & arrayParole(0) & "%'"
If Ubound(Arrayparole)>0 then
Istringa = Istringa & Legame & " keyword LIKE '%"&arrayParole(1)&"%'"
'Istringa = Istringa & Legame & " titolo_libro LIKE '%"&arrayParole(1)&"%'"
If Ubound(Arrayparole)>1 then
Istringa = Istringa & Legame & " keyword LIKE '%"&arrayParole(2)&"%')"
'Istringa = Istringa & Legame & " titolo_libro LIKE '%"&arrayParole(2)&"%')"
Else
Istringa = Istringa &")"
End if
Else
Istringa = Istringa & ")"
End if
strSQL = strSQL & " WHERE "&Istringa
End if
If Genere <> "NULLO" AND Parole<>"" then
SELECT CASE Genere
CASE "Blu"
IIstringa =" AND (Genere='Blu')"
CASE "Fantascienza"
IIstringa ="AND (Genere='Fantascienza')"
END SELECT
strSQL =strSQL & IIstringa
Elseif Genere <> "NULLO" AND Parole="" Then
SELECT CASE Genere
CASE "Agricoltura"
IIstringa =" WHERE (Genere='Agricoltura')"
CASE "Amministrazione"
IIstringa =" WHERE (Genere='Amministrazione')"
CASE "Animali"
IIstringa =" WHERE (Genere='Animali')"
CASE "Archeologia"
IIstringa =" WHERE (Genere='Archeologia')"
CASE "Architettura"
IIstringa =" WHERE (Genere='Architettura')"
END SELECT
strSQL =strSQL & IIstringa
End if
SELECT CASE Ordine
CASE "Data"
IIIstringa =" ORDER BY ID DESC"
CASE "titolo_libro"
IIIstringa =" ORDER BY titolo_libro ASC"
CASE "Genere"
IIIstringa =" ORDER BY Genere ASC"
CASE "Visite"
IIIstringa =" ORDER BY clickunici DESC"
CASE "Autore "
IIIstringa =" ORDER BY Autore ASC"
CASE "Prezzo"
IIIstringa =" ORDER BY Prezzo ASC"
END SELECT
strSQL =strSQL & IIIstringa
Dim objConn,ObjRS
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("db\books.mdb")
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open strSQL, objConn, adOpenKeyset
objRS.PageSize = iPageSize
objRS.CacheSize = iPageSize
iPageCount = objRS.PageCount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Write("Nessun record visualizzato!")
Else
objRS.AbsolutePage = iPageCurrent
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objRS.EOF
%>
[b]<%=objRS("titolo_libro")%>[/b]
<%=objRS("descrizione_libro")%>
<%
iRecordsShown = iRecordsShown + 1
objRS.MoveNext
Loop
End If
objRS.Close
Set objRS= Nothing
objConn.Close %>
<p align="center">[b]<font face="Verdana" size="2" color="#0F467D"><% If iPageCurrent <> 1 Then %>
[url="default2.asp?Azione=RICERCA?page=<%= iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>"]< Indietro[/url]
<% End If %>
<% If iPageCurrent < iPageCount Then %>
[url="default2.asp?Azione=RICERCA?page=<%= iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>"]Avanti >[/url]</font>
<% End If %>
<% End If %>
</table>

)
Rispondi quotando