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 7996509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:43:34+00:00 2026-06-04T14:43:34+00:00

I will try and explain this without causing any confusion, first here is the

  • 0

I will try and explain this without causing any confusion, first here is the relevant code:

$week_start_dates = array($start_of_last_week, $start_of_last_week_last_year, $start_of_previous_week);
$week_end_dates   = array($end_of_last_week, $end_of_last_week_last_year, $end_of_previous_week);
$weekname         = array('TW', 'LY', 'PW');

Basically what these arrays contain are start and end dates for the following query:

$leads = array();

for ($i = 0; $i < sizeof($week_start_dates) ; $i++)
{
        $sql = '
    SELECT
        email.country,
            email_dailytotal.summarydate,   
            sum(email_dailytotal.conversions) as leads      
        FROM email_dailytotal
            left join email on email.email_id = email_dailytotal.email_id
            left join email_type on email.type = email_type.type_id
        WHERE                
            email_dailytotal.summarydate >= "' . $week_start_dates[$i] . '" and email_dailytotal.summarydate <= "' . $week_end_dates[$i]  . '" and email.business = "' . $business .'" and email.business_division = "' . $businessdivision .'"
    GROUP BY email.country
    ';

$dbresult = mysql_query($sql);

while($results = mysql_fetch_array($dbresult)) {
        $country        = $results['country'];
        $no_leads       = $results['leads'];

        array_push($leads, array(
            $country => array(
               $weekname[$i]=>$no_leads
            )
        ));
}

The output is as follows:

[0] => Array
    (
        [uk] => Array
            (
                [TW] => 10334
            )

    )

[1] => Array
    (
        [de] => Array
            (
                [TW] => 315
            )

    )

 [2] => Array
    (
        [uk] => Array
            (
                [LY] => 18579
            )

    )

[3] => Array
    (
        [de] => Array
            (
                [LY] => 401
            )

    )

    [4] => Array
    (
        [uk] => Array
            (
                [PW] => 13410
            )

    )


etc...

When I’d love it to be:

[0] => Array
    (
        [uk] => Array
            (
                [TW] => 10334
                [LY] => 18579
                [PW] => 13410
            )

    etc...

    )
  • 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-06-04T14:43:35+00:00Added an answer on June 4, 2026 at 2:43 pm
    while($results = mysql_fetch_array($dbresult)) {
            $country        = $results['country'];
            $no_leads       = $results['leads'];
    
            if( !isset($leads[$country]) ){
                $leads[$country] = array();
            }
            $leads[$country][$weekname[$i]] = $no_leads;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going to try and explain this without showing any code because I don't
OK, this is impossible, but I will try to explain the situation here. Let's
I don't know how to explain this but I will try. Here is what
sorry for asking this dumb question i will try to explain as good as
I'm going to try to explain this best I can I will provide more
Okay, this scenario is a little complicated, but I will try to explain it
First I will try to explain what I want to do. The app loads
I'm not too sure how to explain this, but I will try. I have
Ok I will try to explain this as much as possible. I have a
So this is a bit complicated situation, so I will try to explain what

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.