I want to know how to display report by month using PHP and Mysql
Example of Report on the web page:
January 2011
==============
Store Name | Total Order Cost
SHOP A | £123
SHOP B | £100
February 2011
==============
Store Name | Total Order Cost
SHOP A | £123
SHOP B | £100
SHOP C | £99.40
I have mysql tables
tbl_shop
-
ShopID
-
ShopName
tbl_order
-
OrderID
-
ShopID
-
OrderDate
-
Total
You will need to iterate trough the result of the query and create an multidimensional array using the month/year combination as keys. The query below should be a good indication on how to fetch the required information from your database.
Note that I havn’t tested this query – please handle it as pseudo-code. You might need to throw around the GROUP BY fields a little and test if it works.