Dans cette fiche... |
Plus facile
maintenant : on liste les sites de la catégorie "Moteur de
recherche".
Seules les requêtes SQL de bases sont à modifier.
<%@ LANGUAGE="VBSCRIPT" %> <HTML> <HEAD> <TITLE>Exemple</TITLE> </HEAD> <BODY> <% dim objConnect dim objRecordset set objConnect = Server.CreateObject("ADODB.Connection") objConnect.Open "WebDB"' Requêtes SQL set objRecordset = Server.CreateObject("ADODB.Recordset") strSQL1 = "SELECT * FROM [rqt Sites+Catégorie] WHERE CodeCatégorie='018' ORDER BY DateEnreg DESC;" objRecordset.Open strSQL1, objConnect, 3 %> <P><FONT FACE="Verdana" COLOR="#004080"><BIG><BIG><STRONG> Liste des sites </STRONG></BIG></BIG></FONT></P> <FONT FACE="Verdana" SIZE="3"> <% intSites = objRecordset.RecordCount if intSites = 0 then Response.Write("Aucun site dans cette liste !") else Response.Write(intSites) & " site" if intSites > 1 then Response.Write("s") end if %> </FONT> <P> <FONT FACE="Verdana" SIZE="2"> <% intSite = 1 Do While not objRecordset.eof %> <!-- Un site --> <DIV ALIGN="center"><CENTER> <TABLE border="0" width="80%" cellspacing="1" cellpadding="2"> <tr> <td width="50%" colspan="2" bgcolor="#004080"><img src="icoTriangleRouge.gif" width="10" height="10"> <font color="#FFFFFF"><strong> <%=intSite & " - " & objRecordset("NomSite")%> </strong></font></td> <td width="50%" colspan="2" bgcolor="#ECECF4"><p align="right"> <% if objRecordset("WebMaster") <> "" then Response.Write("WebMaster : " & objRecordset("WebMaster")) end if %> </td> </tr> <tr> <td width="100%" colspan="4" bgcolor="#ECECF4"> <% ' Supprimer les dièses et les portions d'URL inutiles strURL = objRecordset("URL") i = InStr(strURL, "#") if i > 0 then strURL = mid(strURL, i) strURL = Replace(strURL, "#", "") ' Créer un lien hypertexte en HTML Response.Write("<A HREF=" & chr(34) & strURL & chr(34) & ">" & strURL & "</A>") %> </td> </tr> <tr> <td width="25%" bgcolor="#ECECF4" align="center"><%=objRecordset("Catégorie")%></td> <td width="25%" bgcolor="#ECECF4" align="center"><%=objRecordset("Langue")%></td> <td width="25%" bgcolor="#ECECF4" align="center"><%=objRecordset("DateEnreg")%></td> <td width="25%" bgcolor="#ECECF4" align="center"> <% n = objRecordset("Note") for i = 1 to n Response.Write( "<IMG SRC=" & chr(34) & "icoBouleOrange.gif" & chr(34)&">" ) next %> </td> </tr> <tr> <td width="100%" colspan="4" bgcolor="#D5EAFF"><font color="#000000"> <% if Isnull(objRecordset("Description")) then Response.Write(" ") else Response.Write(objRecordset("Description")) end if %> </font></td> </tr> </TABLE> </CENTER></DIV> <% objRecordset.MoveNext intSite = intSite + 1 loop set objRecordset=nothing set objRecordset2=nothing set objConnect=nothing %> </FONT> </P> </BODY> </HTML>
Seules les nouveautés sont commentées.
Les codes entre < et > concernent l'affichage par HTML classique.
strSQL1 = "SELECT * FROM [rqt Sites+Catégorie] WHERE CodeCatégorie='018' ORDER BY DateEnreg DESC;" |
Dans la base, les moteurs de recherche ont pour
CodeCatégorie 018 (champ Texte). Il suffit donc d'aménager
la clause SQL pour en tenir compte.
On aurait pu également faire la comparaison sur le champ Catégorie, qui
est plus clair. Du genre : |