Question
Display record count in a comments application
Hi, in my application, i try to display the number of
comments for each subject in a list. The problem is that the total
number of records are returned by the loop query for each subject,
even if the there is no comments for the subject related. Anybody
can help me? Here is the code :
<cfquery name="Qsujets" datasource="Modules_Web">
SELECT *
FROM dbo.Sujet
ORDER BY SUJ_ID
DESC
</cfquery>
<cfquery name="Qcommentaire" datasource="Modules_Web">
SELECT *
FROM dbo.Commentaire
</cfquery>
<html>
<head>
<title>Liste des sujets</title>
<link href="/sites/1676/commentaires/CSS/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Liste des articles </h1>
<br />
<cfoutput query="Qsujets">
<ul><li>
<span class="sujets">#Qsujets.SUJ_Nom#</span><br />
<span class="auteur">#Qsujets.SUJ_Auteur#</span><br />
<span class="description">#Qsujets.SUJ_Description#</span><br />
<div id="bloc_sujet">
<table>
<tr>
<td><img src="/sites/1676/commentaires/images/oeil.gif" alt="Lire les réactions " width="20" height="20" /></td>
<td><a href="/index.cfm/2,0,1676,9914,2832,0,html?COM_ID=#Qsujets.SUJ_ID#">Lire les réactions à cet article </a> (#Qcommentaire.RecordCount#)</td>
<br />
</tr>
<tr>
<td><img src="/sites/1676/commentaires/images/comment.gif" alt="Réagir" width="20" height="19" /></td>
<td><a href="liste_com.cfm?COM_ID=#Qsujets.SUJ_ID#"></a><a href="/index.cfm/2,0,1676,9914,2831,0,html?SUJ_ID=#Qsujets.SUJ_ID#">Réagir à cet article</a></td>
</tr>
</table>
______________________________________</div>
</li></ul>
</cfoutput>
</body>
</html>
<cfquery name="Qsujets" datasource="Modules_Web">
SELECT *
FROM dbo.Sujet
ORDER BY SUJ_ID
DESC
</cfquery>
<cfquery name="Qcommentaire" datasource="Modules_Web">
SELECT *
FROM dbo.Commentaire
</cfquery>
<html>
<head>
<title>Liste des sujets</title>
<link href="/sites/1676/commentaires/CSS/styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Liste des articles </h1>
<br />
<cfoutput query="Qsujets">
<ul><li>
<span class="sujets">#Qsujets.SUJ_Nom#</span><br />
<span class="auteur">#Qsujets.SUJ_Auteur#</span><br />
<span class="description">#Qsujets.SUJ_Description#</span><br />
<div id="bloc_sujet">
<table>
<tr>
<td><img src="/sites/1676/commentaires/images/oeil.gif" alt="Lire les réactions " width="20" height="20" /></td>
<td><a href="/index.cfm/2,0,1676,9914,2832,0,html?COM_ID=#Qsujets.SUJ_ID#">Lire les réactions à cet article </a> (#Qcommentaire.RecordCount#)</td>
<br />
</tr>
<tr>
<td><img src="/sites/1676/commentaires/images/comment.gif" alt="Réagir" width="20" height="19" /></td>
<td><a href="liste_com.cfm?COM_ID=#Qsujets.SUJ_ID#"></a><a href="/index.cfm/2,0,1676,9914,2831,0,html?SUJ_ID=#Qsujets.SUJ_ID#">Réagir à cet article</a></td>
</tr>
</table>
______________________________________</div>
</li></ul>
</cfoutput>
</body>
</html>
