Hello,
I wrote this simple query:
<?php
include("db.php");
$query = "SELECT glossarycategoryid, glossaryname, glossaryid FROM glossary WHERE glossarycategoryid = '14' ORDER BY glossaryname";
$res = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($res)) {
$glossaryname = $row["glossaryname"];
$glossaryid = $row["glossaryid"];
echo "<a href=\"glossary.php?do=viewglossary&term=$glossaryid\">$glossaryname (";
$dquery = "SELECT title FROM thread WHERE title LIKE '$glossaryname - %' AND forumid = '105'";
$dres = mysql_query($dquery) or die(mysql_error());
while($row = mysql_fetch_array($dres)) {
$comm = mysql_num_rows($dres);
}
if ($comm >= 1) {
echo "$comm textes)<br>";
}
}
?>
Basically it will list all "title" entrys of a specific category from "glossary" table, then it will look for entrys beginning with the title we previously found and return the number of results found.
My problem is that when no results are found, instead of displaying a zero or nothing it will display the number of results found from the previous entry
exemple:
the normal result would be
category 1 (50 texts)
category 1 (100 texts)
category 1 (500 texts)
category 1 (0 texts)
category 1 (10 texts)
but script returns:
category 1 (50 texts)
category 1 (100 texts)
category 1 (500 texts)
category 1 (500 texts)
category 1 (10 texts)