LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-26-2012, 09:51 AM   #1
countrydj
Member
 
Registered: Jun 2009
Location: Preston, England
Distribution: Centos 6
Posts: 127

Rep: Reputation: 1
Counting votes not displaying right


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 ???
 
Old 07-27-2012, 10:28 AM   #2
Sydney
Member
 
Registered: Mar 2012
Distribution: Scientific Linux
Posts: 147

Rep: Reputation: 36
I just skimmed it but I didn't see a where x = ".$category."
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
odbc (php output not displaying in web browser,but it displaying in terminal) manu@vssc Red Hat 1 06-29-2011 01:33 AM
The votes are in: New Slack, New Tagline... tallship Slackware 11 03-16-2011 07:37 PM
LXer: Apache votes no on Java EE 6 LXer Syndicated Linux News 0 03-05-2009 09:51 PM
LXer: Probe into votes on Microsoft standard LXer Syndicated Linux News 0 03-06-2008 05:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration