Dans cette fiche...

<Retour ASP>

Début de page Principe

On liste ici les meilleurs sites (Best Of), c'est-à-dire les sites qui ont une note de 5.

Début de page Listing de la page ASP

<%@ 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 Note=5 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("&nbsp;")
	   else
		Response.Write(objRecordset("Description"))
	   end if
	%>
    </font></td>
  </tr>

</TABLE>
</CENTER></DIV>

&nbsp;

<%		
	objRecordset.MoveNext
	intSite = intSite + 1
	loop

	set objRecordset=nothing
	set objRecordset2=nothing
	set objConnect=nothing
%>
</FONT>
</P>
</BODY>
</HTML>

 

Début de page Le listing en détail...

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 Note=5 ORDER BY DateEnreg DESC;"
Cette requête SQL est la seule différence par rapport aux listings précédents. No comment !