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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:04:19+00:00 2026-05-26T06:04:19+00:00

I’ve never done this before, so im lost here. I have the following transactions

  • 0

I’ve never done this before, so im lost here.

I have the following transactions table:

transaction_id  transaction_user    transaction_ammount transaction_time
1                     2                   950              1318482908
2                     2                   750              1318482916
3                     2                   950              1318482939

Then, I need to create a query, that helps me pull Weekly data, Grouped by Day so I can create a Chart, you get me?

I’ve got this so far in PHP that detects the week number and prints the complete Week Days (Im using phpbb3):

    $format = 'l'; 
    $ts = time();   // set current Unix timestamp
    $today = date($format, $ts); // set today
    $year = date('o', $ts);
    $week = date('W', $ts);
    $weekdays = 7; 


    for($i = 1; $i <= $weekdays; $i++) 
    {
        // timestamp from ISO week date format
        $ts = strtotime($year.'W'.$week.$i);

        $day = date($format, $ts);
        // test if $day is $today
        if ($day == $today) {
            $day = '<strong>' . $day . '</strong>';
        }

        $template->assign_block_vars('time', array(
            'DATE'                  => $day,
        ));
    }

Now, I want to arrange the total sales that happened on Monday, Tuesday, …. 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-05-26T06:04:20+00:00Added an answer on May 26, 2026 at 6:04 am

    this mysql query

    select week(transaction_time) as weekno, weekday(transaction_time) as dayno, sum(transaction_ammount) as total_amount
    group by     week(transaction_time), weekday(transaction_time)
    

    will give you this result set

    |weekno|dayno|total_amount
    

    here are some references to those functions in mysql so you can interpret the data

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week

    http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_weekday

    UPDATE, try this sql as it might need to convert the timestamps for the other functions to work properly

    select week(FROM_UNIXTIME(transaction_time)) as weekno, weekday(FROM_UNIXTIME(transaction_time)) as dayno, sum(transaction_ammount) as total_amount
    group by    week(FROM_UNIXTIME(transaction_time)), weekday(FROM_UNIXTIME(transaction_time))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.