Soyez le premier à donner votre avis sur cette source.
Snippet vu 11 085 fois - Téléchargée 31 fois
<html> <head> <title></title> <script><!-- function newWindow_Preview(url, name, crtctrstsc){ window.open(url, name, crtctrstsc) } //--></script> </head> <body> <%@LANGUAGE = JScript%> <% var Cn = new ActiveXObject("ADODB.Connection"); var Sc = "driver={Microsoft Access Driver (*.mdb)};dbq=" + Server.MapPath("showRoom/base.mdb"); Cn.Open(Sc); var Sql = "SELECT * FROM url ORDER BY id "; var Mostra = new ActiveXObject("ADODB.Recordset"); Mostra.Open(Sql,Cn, 1); var conta = 0; var pag = parseInt(Request.QueryString("id")); if (isNaN(pag) || pag < 1) pag = 1; if (!Mostra.EOF) { Mostra.PageSize = 9; Mostra.AbsolutePage = pag; } var i = 0; if (pag==1) inicio=1 else inicio=1+(pag-1)*Mostra.PageSize fin=inicio+Mostra.PageSize-1 if (fin > Mostra.recordcount) fin =Mostra.recordcount %> <p align="center"><font face="Tahoma"><span style="font-size:10pt;"><b>Galerie d'images</b></span></font></p> <p><font face="Tahoma" size="2">Nombre d'images par page:<font color="#FF0000"><b> <%=Mostra.PageSize%> </b></font><b><font color="#FF0000"> </font><font color="#000000">-</font><font color="#FF0000"> </font></b>Affichage des images [<font color="red"><b><%=inicio%> - <%=fin%></font></b>] sur un total de<font color="#FF0000"> <b><%=Mostra.recordcount%> </b></font> - page<font color="#FF0000"><b> <%=pag%> </b></font>sur<font color="#FF0000"> <b><%=Mostra.PageCount%></b></font></p> <table align="center" cellpadding="0" cellspacing="0" height="129" bgcolor="#C0C0C0"> <% while (!Mostra.EOF && i<9) { i++ // Impostiamo la condizione secondo la quale se arriviamo a 3 record andremo a capo con </tr> e <tr> if (conta == 3) //Mettez ici le nombre d'enregistrement par ligne { conta = 0; // Resettiamo il contatore impostandolo su zero (0) %> <tr><td onmouseover="javascript:this.style.backgroundColor='gray'" onmouseout="javascript:this.style.backgroundColor=''" width="200" height="129"><p align="center"><a href="javascript:newWindow_Preview('showing.asp?imgID=<%=Mostra("id")%>','preview','scrollbars=yes, status=yes, height=300, width=500')" title="<%=Mostra("nom")%>"><%=Mostra("adresse")%></a></td> <% } // altrimenti restiamo sulla stessa riga else { %> <td onmouseover="javascript:this.style.backgroundColor='gray'" onmouseout="javascript:this.style.backgroundColor=''" width="200" height="129"><p align="center"><a href="javascript:newWindow_Preview('showing.asp?imgID=<%=Mostra("id")%>','preview','scrollbars=yes, status=yes, height=300, width=500')" title="<%=Mostra("nom")%>"><%=Mostra("adresse")%></a></td> <% } conta++; // Incrementiamo la variabile contatore Mostra.moveNext() } %> </tr> </table> <table border="0" width="100%"> <tr> <td width="100%"></td> </tr> </table> <div align="center"> <center> <table width="412" height="1"> <tr> <td width="183" height="1"> <%if (pag > 2 && Mostra.PageCount > 2) {%><font face=tahoma size=2><a href="galerie.asp?id=<%=1%>">Premier</a><%}%> <%else if (Mostra.PageCount<=2) {%> <%}%> <%else {%><font face=tahoma size=2 color="#C0C0C0">Premier</font></font></font><font face="tahoma" size="2" color="#C0C0C0"> </font><font face=tahoma size=2><font face="Tahoma" size="2"> <%}%> <%if (pag > 1) {%> </font></font><font face="Tahoma" size="2"><font face=tahoma size=2><a href="galerie.asp?id=<%=pag - 1%>"><< Précédent</a><%}%> <%else {%><font face=tahoma size=2 color="#C0C0C0"><< Précédent<%}%> </font> </font> </font> </td> <td width="65" height="1"><p align="center"><% for (var i=0; i<Mostra.PageCount; i++) { if (pag == (i + 1)) { %> <b><%=(i + 1)%></b> <%} else {%> <a href="galerie.asp?id=<%=(i + 1)%>"><%=(i + 1)%></a> <% } } %> </p></td> <td width="189" align="right" height="1"> <p align="center"> <%if (!Mostra.EOF) {%><font face=tahoma size=2><a href="galerie.asp?id=<%=pag + 1%>">Suivant >></a><%}%> <%else {%><font color=#C0C0C0 face=tahoma size=2>Suivant >><%}%> <%if (!Mostra.EOF && pag < Mostra.PageCount-1) {%> <font face=tahoma size=2><a href="galerie.asp?id=<%=Mostra.PageCount%>">Dernier</a><%}%> <%else if (Mostra.PageCount<=2) {%> <%}%> <%else {%> <font color=#C0C0C0 face=tahoma size=2>Dernier<%}%><font face=tahoma size=2> </font> </td> </tr> </table> </center> </div> <%Cn.Close()%> </body> </html>
19 avril 2005 à 18:24
si tu as une variable NbreSaut = 10 ki te donne le nombre de record suivants ou précédents à trouver,
tu remplace "select top 10" par "select top " & NbreSaut & "..." et 20 pas (2*NbreSaut)
et sur "précédent", tu fait
où x est le num en cours
Voilà, c peut-être pas trés clair, mais c plus simple en fait, et ça surcharge pas le serveur bdd.
Avec 10-500 renregistrements, ta méthode est valable, mais si tu en as plus , ça craint !!
happy coding ...
19 avril 2005 à 18:19
SELECT * FROM (select top 10 * from (select top 20 * FROM URL order by ID ASC) as Url1 order by ID DESC) as Url2 ORDER BY ID ASC
et ça évitera des boucles j'usqu'à NumEnCours Num paske si bcp record> c pas gangé !! surtout avec access !
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.