Hi Guys...
I'm still struggling with my problem.
However, I have made good progress.
This is the code that I am using:
PHP Code:
//######################### DUO #######################
$main_content .= '<td width=33% valign=top>';
$category = "Duo of the year award UK:";
$table = "duo";
$main_content .= '<br><font size=2 color="#ffff00"><b>'.$category.'</b></font><p>';
$qry = "SELECT ".$table.", COUNT(duo) FROM ". $directory4 ." GROUP BY ".$table." order by COUNT(duo) DESC LIMIT 6";
if(!($results = mysql_query($qry, $link))){
displayErrMsg(sprintf("Error in executing %s query", $qry));
displayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link)));
exit();
}
$numresults = mysql_num_rows($results);
echo $numresults;
if($numresults > 0){
while($row = mysql_fetch_array($results)){
$list = $row['duo'];
$main_content .= '<b><font size=2>'.$list.' ('.$row['COUNT(duo)'].')</b>';
$main_content .= '<br />';
}
$qry = "SELECT ".$table.", COUNT(duo) FROM ". $directory4 ." order BY COUNT(duo)";
$result = mysql_query($qry) or die(mysql_error());
// Print out TOTAL result
while($row = mysql_fetch_array($result)){
$main_content .= '<br /><b><font size=2>Total votes = '.$row['COUNT(duo)'].'</b><p>';
}
}
else {
$main_content .= '<b><font size=2>No votes';
}
$main_content .= '</td>';
This displays:
Quote:
Duo of the year award UK:
(14)
McKenzie (1)
Total votes = 15
|
The problem is that there is only 1 vote for Duo of the year.
However, there are a total of 15 voters. i.e. 14 voters for other categories and 1 voter for Duo category.
You should notice that I have placed a 'test' in the code:
PHP Code:
echo $numresults;
which displays 2
I would have thought that it should display 1 since there is only 1 entry in the duo table.
Can anybody see what is wrong with my code ???