Bonjour,
Comment puis-je paginer mes pages tout en gardant en mémoire ma requête SQL.
La question est simple et courante dans les sites dynamiques, mais je ne m'en sort pas. (pôôôvre novice que je suis)
L'affichage de la première page marche. Il affiche dans le navigateur:www.monsite.com/mapage.asp?rub=mode_homme
Par contre, quand j'utilise ma pagination pour aller en page 2, ça affiche dans le navigateur: www.monsite.com/mapage.asp?num=8
C'est normal, je vois bien qu'il y a une grosse erreur, mais je ne trouve pas comment faire. Dans mes tests, j'en suis arrivé à cette réponse de navigateur, mais sans succès: www.monsite.com/mapage.asp?rub&num=8
Merci de m'aider, je me noie
Le code de la page ci-dessous:
Sql= "Select * from luxe WHERE rubrique='" & request("rub") & "' order by nom_sans_pub,nom_avec_pub asc;"
Set Rs = Server.CreateObject("ADODB.Recordset") Rs.open Sql,Conn,3,3
' On choisit de faire trois colonnes Nbcol=2 NbTot=rs.recordcount' Il y a un total de NbTot enregistrements Nmin = 4 ' nombre par colonne Nmax=Nmin*NbCol Ncur = 0 ' n° de la fiche courante Ndeb = 0 ' 1ère fiche transmise par l'URL if request.queryString("num")<>"" then _ Ndeb = Cint(request.queryString("num"))
' Il va falloir un certain nombre de lignes if (NbTot/NbCol)=Cint(NbTot/NbCol) then NbLigne=NbTot/NbCol else NbLigne=1+Cint(NbTot/NbCol) end if ' Premier enregistrement Lig=0 ' Pour savoir sur quelle ligne on est response.write "<table width=100% height=95% border=1><tr><td width=50% valign=top>" while not RS.eof and Ncur<Nmax+Ndeb ' si elle est à afficher if Ncur >= Ndeb then response.write "<IMG SRC="&rs("logo_diamant")&"> <strong><font size=1 face=Verdana, Arial, Helvetica, sans-serif>" & rs("nom_sans_pub")&"</strong> </font><strong><font color=#6B0B0C size=1 face=Verdana, Arial, Helvetica, sans-serif>" & rs("nom_avec_pub")&"</strong> </font><font size=1 face=Verdana, Arial, Helvetica, sans-serif> <a href=fiche_info.asp?id="&rs("id")&" target=_blank>[Fiche info]</a> <IMG SRC="&rs("logo_pays")&"> <br> "&rs("signalement_liste")&"<br><br><a href="&rs("website")&" target=_blank>[Aller sur le site internet]</a> <a href="&rs("lien_event")&" target=_blank>"&rs("zevent")&"</a></font><br><b r>" Lig=Lig+1 If Lig=Nmin then response.write "</td><td width=50% valign=top>":Lig=0:end if ' enregistrement suivant end if ' fiche suivante RS.MOVENEXT ' une de plus Ncur = Ncur + 1 wend response.write "</td></tr></table>"%> <table cellpadding=3> <tr> <% ' Navigation ' Des fiches avant ? if Ndeb > 0 then%> <td> <A href="?num=<%=Ndeb-Nmax%>">Retour</A> </td> <%end if ' N° des pages Npag = int(RS.recordCount/Nmax) if Npag < RS.recordCount/Nmax then Npag = Npag + 1 for i = 1 to Npag%> <td> <% ' Page courante ? if Ndeb = (i-1)*Nmax then%> <%=i%> <%else%> <A href="?num=<%=(i-1)*Nmax%>" ><%=i%></A> <%end if%> </td> <%next ' Des fiches après ? if not RS.eof then%> <td> <A href="?num=<%=Ncur%>">Suite</A> </td> <%end if RS.close : set RS=nothing%> </tr> </table> <% conn.close set conn=nothing %>
|