Ciao, ho un problema sulla paginazione dei risultati di una ricerca.
Cioè facendo la ricerca delle informazioni, una volta trovati gli elementi, ho difficoltà nel paginarli.
In effetti il problema mi sorge perchè ogni volta che tento di raggiungere la pagina successiva,
lo script mi ricontrolla se sono state immesse informazioni nel campo input ed effettua il controllo,
scartando altre possibilità.
Tralasciando un po' di codice Htlm, lo script è questo:
codice:
<%
' Verifica input
cerca = lcase(replace(request.form("nome"),"'","''"))
if request("nome") <> "" then
nomericerca = 1
' Verifica nela campo ricerca
nome_ric = replace(request.form("ricerca"),"'","''")
If nome_ric <> "comune" then
nome_ric = "nome"
End If
' Prepariamo i records per ogni pagina
RecordsPerPage = 12
Page = Request.QueryString("page")
If Len(page) > 0 And IsNumeric(page) Then
page = CLng(page)
Else
Page = 1
End If
' Prepariamo la SQL per la ricerca
dim sql, rs
Set Rs = Server.CreateObject("ADODB.Recordset")
sql = "select id, tipo_struttura, nome, comune from strutture where
visibile=true and " & nome_ric & " like '%"&cerca&"%' Order by
comune, tipo_struttura, nome ASC"
Rs.open SQL, Conn, 1, 3
' Se non troviamo nulla
If rs.EOF then %>
...........
<%
Else
Rs.PageSize = RecordsPerPage
Rs.AbsolutePage = Page
%>
Strutture in Elenco: <%=rs.RecordCount> Pagina <%=Page%>
di<%=rs.PageCount%>
<%
recordcount = (RecordsPerPage * (Page - 1))
For x = 1 To RecordsPerPage
If Not Rs.EOF Then
recordcount = recordcount + 1
%>
............
<%
Rs.MoveNext
End If
Next
%>
......
<%
pageup = page
pageoff = rs.pagecount
if pageup <> pageoff then
pageup = pageup + 1
else nopageup = true
end if
pagedown = page
pagedown = pagedown - 1
if pagedown = 0 then
nopagedown = true
end if
%>
.......
<%="Vai alla pagina: "%>
<%
For i = 1 To Rs.PageCount
If i = page Then
Response.Write"(" & i & ")"
Else
Response.Write " "& i &" "
End If
Next
Rs.Close
Set Rs = Nothing
End if
Conn.Close
Set Conn = Nothing
%>
</td>
<td width="100" align="left"><%if nopagedown = true then%>
<font face="Arial" size="2">◄</font>
<font face="Arial" size="1">PRECEDENTE</font><%else%>
<a title="Pagina precedente" href="cerca.asp?page=<%=pagedown%>"
style="text-decoration: none"><font face="Arial" size="2">◄</font>
<font face="Arial" size="1">PRECEDENTE</font></a><%end if%></td>
<td width="100" align="right"><%if nopageup = true then%>
<font size="1" face="Arial">SUCCESSIVO</font>
<font face="Arial" size="2">►</font>
<%else%>
<a title="Pagina successiva" href="cerca.asp?page=<%=pageup%>"
style="text-decoration: none">
<font size="1" face="Arial">SUCCESSIVO</font>
<font face="Arial" size="2">►</font></a>
<%end if%>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="200">
<tr>
<td width="100%" align="center">
<a title="Torna Indietro" href="javascript:history.back()"
style="text-decoration: none">
<font size="2" face="Arial">◄◄ </font>
<font size="1" face="Arial">INDIETRO</font></a></td>
</tr>
</table>
<%
Else
nomericerca = 0 %>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="588">
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="100%">
<tr>
<td width="100%" align="center" height="30">
<font face="Arial" color="#003366" size="5">! !
ERRORE ! !</font></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0"
style="border-collapse: collapse" width="100%" height="18">
<tr>
<td width="100%" height="35" align="center">
<font color="#800000" face="Arial">
Inserisci un nome per favore</font></td>
</tr>
</table>
</p>
</td>
</tr>
</table>
</center>
</div>
<%End if%>
Che soluzione adottare??
Grazie a tutti.