extra | Bonjour,
Je suis loin d'être un pro en ASP (c'est pour cela que je sollicite votre aide...)
Sur une base de données, je voudrai faire une recherche par mot clé, et afficher le tout avec 5 résultats par pages.
La première page, ça fonctionne, mais les suivantes, ca bug c'est normal, car en rechargeant la page il fait la relecture du formulaire qui du coup est vide...
Comment faire S.V.P.
Merci
la page en question (le serveur est Down à l'heure ou j'écris mais cela ne devrait pas durer)http://www.ac-nancy-metz.fr/pres-e [...] /liste.asp
le code
Code :
- <!-- #include file="_connexion.asp"-->
- <html>
- <head>
- ...
- </head>
- ... bla bla
- <html>
- <body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
- <form method="POST" name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)" language="JavaScript" action="listeR.asp">
- <b>Trier par : <a href="listeN.asp">nom</a>, <a href="listeS.asp">section</a>,
- <a href="listeA.asp">année</a> </b>
- <!--webbot bot="Validation" b-value-required="TRUE" i-minimum-length="2" -->
- <input type="text" name="recherche" size="20">
- <input type="submit" value="Rechercher" name="B1"></form>
- <%mot1=Request.Form("recherche" )
- mot=Replace(mot1,"'","''" )
- mot=Replace(mot,"<","<" )
- mot=Replace(mot,">",">" )%>
- <%if mot="" or mot=" " then%>
- <b>
- Vous n'avez rien saisi !<BR>Merci d'écrire le nom à trouver sur
- cet annuaire, puis de valider en cliquant sur "Rechercher"!<BR>
- </b>
- <%else%>
- <%Nmax = 5 ' nombre par page
- Ndeb = Cint(request.queryString("num" ))
- ' nombre total de fiches
- SQL="SELECT count(*) FROM histo"
- RS2 = conn.execute(SQL)
- Ntotal = RS2(0) - 1 ' commence à 0
- ' sélectionne les fiches de la table
- Set RS = server.createobject("ADODB.Recordset" )
- SQL="SELECT TOP " & (Ndeb+Nmax) & " * FROM histo where nom like '%"&mot&"%' or prenom like '%"&mot&"%' or classe like '%"&mot&"%' or annee like '%"&mot&"%' order by nom"
- RS.Open SQL,Conn , 3, 3%>
- Il y a <%=ntotal%> enregistrements d'anciens élèves :
- <div align="center">
- <table border="4" cellspacing="1" cellpadding="5" id="table12">
- <%' Avance à la 1ère
- RS.Move(Ndeb)
- ' tant qu'il reste des fiches
- while not RS.eof
- ' affiche le champ%>
- <tr>
- <td valign="top" align="center"><a>
- <p style="margin-top: 0; margin-bottom: 0"><%=response.write(Server.HTMLEncode(rs.Fields("prenom" ).Value))%></p>
- <p style="margin-top: 0; margin-bottom: 0"><b><%=response.write(Server.HTMLEncode(rs.Fields("nom" ).Value))%></b></p>
- </td>
- <td align="center" valign="top"><a>
- <p style="margin-top: 0; margin-bottom: 0"><%=response.write(Server.HTMLEncode(rs.Fields("classe" ).Value))%></p> </a><%=response.write(Server.HTMLEncode(rs.Fields("annee" ).Value))%></td>
- <td align="center" valign="middle"><a>
- <p style="margin-top: 0; margin-bottom: 0">
- <% email = Server.HTMLEncode(rs.Fields("email" ))%>
- <% if email = "pas de mail" then%>
- <img border="0" src="../images/Noemail.gif" width="28" height="31">
- <% else%>
- <a href="mailto:<%=response.write(Server.HTMLEncode(rs.Fields("email" ).Value))%>?subject=Anciens élèves du lycée Loritz">
- <img border="0" src="../images/email.gif" width="28" height="31"></a></td>
- <% end if%>
- <td><a>
- <p style="margin-top: 0; margin-bottom: 0"><%=response.write(Server.HTMLEncode(rs.Fields("commentaire" ).Value))%></a> </tr>
- <%RS.MOVENEXT
- wend%>
-
- </table></div>
- </BODY></HTML>
- </center>
- </td>
- </tr>
- </table>
- </body>
- <div align="center">
- <table cellpadding=0 id="table13" border="0" cellspacing="0">
- <tr>
- <% ' NAVIGATION
- ' Des fiches avant ?
- if Ndeb > 0 then%>
- <td><b><A href="?num=0"><span style="text-decoration: none">
- <img border="0" src="../images/test.a1.gif"></span></A> </b> <b><A href="?num=<%=Ndeb-Nmax%>"><span style="text-decoration: none"><img border="0" src="../images/test.a2.gif"></span></A>
- </b> </td>
- <%end if%>
- <td>
- <% ' Page courante
- Npag = int(Ndeb/Nmax)+1 : Npag2 = Npag-1
- tmp = "<b>" & Npag & "</b>"
- ' Max 3 pages avant
- while Npag2>0 AND Npag2>Npag-4
- tmp = "<A href='?num=" & ((Npag2-1)*Nmax)_
- & "'>" & Npag2 & "</A> " & tmp
- Npag2 = Npag2-1
- wend
- ' Max 9 pages après
- Npag2 = Npag
- while Npag2*Nmax<=Ntotal AND Npag2<Npag+3
- Npag2 = Npag2+1
- tmp = tmp & " <A href='?num=" & ((Npag2-1)*Nmax)_
- & "'>" & Npag2 & "</A>"
- wend
- response.write tmp
- %>
- </td>
- <% ' Des fiches après ?
- if Ntotal>Ndeb+Nmax then%>
- <td><b> <A href="?num=<%=Ndeb+Nmax%>">
- <span style="text-decoration: none">
- <img border="0" src="../images/test.a3.gif"></span></A></b> <b>
- <A href="?num=<%=int(Ntotal/10)*10%>">
- <span style="text-decoration: none">
- <img border="0" src="../images/test.a4.gif"></span></A></b> </td>
- <%end if
- end if
- RS.close : set RS=nothing%>
- </html>
- </div>
- <p> </div>
- </BODY></HTML>
- </div>
- <% conn.close : Set conn=nothing %>
|
|