Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6192677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:59:03+00:00 2026-05-24T02:59:03+00:00

Whatever I do, I cannot get this code to echo $done . Here is

  • 0

Whatever I do, I cannot get this code to echo $done.

Here is an excerpt from my code that I just cannot get to work for the life of me. I have tried it five different ways, but nothing is working. My only conclusion is that it doesn’t work because of UNION.

Is there a way around this? Or is this even the problem?

$query01 = "SELECT COUNT(DISTINCT report) AS ip 
                FROM reports 
                    WHERE country =  '".$country."' 
                    AND YEAR(date) = '2011' 
                    AND MONTH(date) = '".$i."' AND 
                    status ='IP' 
        UNION
            SELECT COUNT(DISTINCT report) AS done 
                FROM reports 
                    WHERE country =  '".$country."' 
                    AND YEAR(date) = '2011' 
                    AND MONTH(date) = '".$i."' 
                    AND status ='DONE'";

$result01 = mysql_query($query01);

while ($row01 = mysql_fetch_array($result01)) {
    $ip = $row01['ip'];
    $done = $row01['done'];
    $all = $ip + $done;

    if($all>0){
        echo "<td>".$ip.":".$done."</td>";
    }

    else{
        echo "<td>-</td>";
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:59:04+00:00Added an answer on May 24, 2026 at 2:59 am

    I guess you are trying to get the ip and done as two columns of each row in which case UNION is not the right choice for the query you have.

    Try this:

        $query01 = "SELECT a.ip, b.done 
      FROM 
        (
        SELECT COUNT(DISTINCT report) AS ip 
                        FROM reports 
                            WHERE country =  '".$country."' 
                            AND YEAR(date) = '2011' 
                            AND MONTH(date) = '".$i."' AND 
                            status ='IP' 
            ) a,
            (
                    SELECT COUNT(DISTINCT report) AS done 
                        FROM reports 
                            WHERE country =  '".$country."' 
                            AND YEAR(date) = '2011' 
                            AND MONTH(date) = '".$i."' 
                            AND status ='DONE'
            ) b";
    
        $result01 = mysql_query($query01);
    
        while ($row01 = mysql_fetch_array($result01)) {
            $ip = $row01['ip'];
            $done = $row01['done'];
            $all = $ip + $done;
    
            if($all>0){
                echo "<td>".$ip.":".$done."</td>";
            }
    
            else{
                echo "<td>-</td>";
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For whatever reason, I have a lot of clients that have existing data that's
We have an engine that loads dlls dynamically (whatever is located in a certain
From the examples that I have read and from the documentation on MysqlConnectionPoolDataSource at
I have this code: public static IEnumerable<dcCustomer> searchCustomer(string Companyname) { TestdbDataContext db = new
I cannot seem to get foreach to work. Maybe I do not understand it
My designer believes this cannot be done, however it seems possible to me. (Although
I have a query that looks like this: Insert Into tblX (a,b,c) Select x
For whatever reason, our company has a coding guideline that states: Each class shall
This gets the value of whatever is selected in my dropdown menu. document.getElementById('newSkill').value I
Am I allowed to add whatever attributes I want to HTML tags such that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.