Jump to content

Recommended Posts

Hello,

 

I have created the below query to get all the totals of sales during a chosen date from 3 date pickers.

My question now is how to get 12 months of results when I choosen a year but have each months output it's total sales.

The reaosn I need this is because I need to have an array showing every month  + total sales per month so I can json_encode() it and pass it into a graph using Morris.js(Graph library) as shown here:

<?php
$query = "SELECT SUM(cust_order_total) AS order_total_sum FROM orders WHERE due_date BETWEEN '2015-08-14' AND '2015-10-14'";
$result = mysqli_query($connection, $query);
while ($row = mysqli_fetch_array($result)){
echo $row['order_total_sum'];//This return totals of sales during chosen period.
    }
?>

This currently output well the total sales during the chosen period, so it works. Now I need the exact same type of logic but When I click on the dropdown menu that choses a Year, I would like to see:

Year 2014

 

Month

01  ->  €239

02  -> €250

03  -> €456

 

And so on....

 

Any idea please?

Remember I am saving the date as yyyy-mm-dd in mysql but read it as dd-mm-yyyy on the web page.

 

Thank you,

 

Ben

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.