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

  • SEARCH
  • Home
  • 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 6665293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:42:28+00:00 2026-05-26T02:42:28+00:00

We are stuck performing this mySQL query and the PHP along side it. Here

  • 0

We are stuck performing this mySQL query and the PHP along side it.

Here is our query:

 SELECT DATE(`Checked`) AS theday, COUNT(`Download ID`) AS thecount, 
`Status` AS thestatus
 FROM `download` 
 WHERE `Checked`>= (CURRENT_DATE - INTERVAL 14 DAY) 
 GROUP BY theday, thestatus ORDER by theday DESC

Here is the PHP:

while ($r = mysql_fetch_array($q)){
    echo "<pre>";
    print_r($r);
    echo "</pre>";
}

Here is a sample output:

Array
(
    [0] => 2011-10-10
    [theday] => 2011-10-10
    [1] => 1
    [thecount] => 1
    [2] => Downloading
    [thestatus] => Downloading
)


Array
(
    [0] => 2011-10-10
    [theday] => 2011-10-10
    [1] => 9
    [thecount] => 9
    [2] => Converting
    [thestatus] => Converting
)

Array
(
    [0] => 2011-10-10
    [theday] => 2011-10-10
    [1] => 2673
    [thecount] => 2673
    [2] => Complete
    [thestatus] => Complete
)

Array
(
    [0] => 2011-10-10
    [theday] => 2011-10-10
    [1] => 366
    [thecount] => 366
    [2] => Aborted
    [thestatus] => Aborted
)

Basically, we want to display the results like this, in a while loop, for each day:

2011-10-10
Downloading: 1
Converting: 9
Complete: 2673
Aborted: 366
Error: 0

We are stuck on how to do the query & the PHP to get the results displayed like this.

We basically want the above example, to be looped 14 times (for the last 14 days), and output like the above example, so it groups the count & status for each day and echos it out like so.

Thank you.

  • 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-26T02:42:29+00:00Added an answer on May 26, 2026 at 2:42 am

    You would need to build an array of date to status data. For example

    $dates = array();
    while ($r = mysql_fetch_assoc($q)) {
        if (!array_key_exists($r['theday'], $dates)) {
            $dates[$r['theday']] = array();
        }
        $dates[$r['theday']][$r['thestatus']] = $r['thecount'];
    }
    

    and to display…

    <dl>
        <?php foreach ($dates as $date => $status) : ?>
            <dt><?php echo htmlspecialchars($date) ?><dt>
            <?php foreach ($status as $key => $count) : ?>
            <dd><?php printf('%s: %d',
                htmlspecialchars($key), $count) ?></dd>
            <?php endforeach ?>
        <?php endforeach ?>
    </dl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kinda stuck here... I have an application with lets say 5000 rows of data
I'm a bit stuck on this. Basically I want to do something like the
I'm stuck on a PHP 4 server, and I would like to start moving
I'm kinda stuck with this one so I hoped someone could help me. I
This query works (thanks to those that helped) to generate a 30-day moving average
This feels like an extremely n00b question, but here goes... I have a series
I am performing a bitwise function on 32- and 64-bit integers, and got stuck
I've been stuck on this question for a while. I have a data file
ASP.NET application performing oAuth with Facebook. This code was working fine until a few
I can't figure out how to implement this in a performing way, so I

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.