Welcome Guest, Not a member yet? Register   Sign In
Codeignitor php array brain teaser problem Help!
#1

[eluser]kiwimediapro[/eluser]
I have the following query:
Code:
SELECT SUM(t1.totalprice) as totalprice,
SUM(t1.sales) as salessubtotal, t1.`year` as `year`,
t1.mnth as `month`
from
(SELECT
Sum(crm_sales.totalprice) AS totalprice,
MONTHNAME(crm_sales.date) AS mnth,
YEAR(crm_sales.date) AS `year`,
Count(crm_sales.totalprice) AS sales,
MONTH(crm_sales.date) AS `ordering`
FROM `crm_sales`
WHERE `date` BETWEEN '2009-01-01' AND '2010-05-28'
GROUP BY crm_sales.date
) as t1
GROUP BY t1.`year`,t1.mnth
ORDER BY t1.`year`, t1.ordering

This returns the following data:
No_Sales Year Month
---------------------------------------
588 2009 September
660 2009 October
524 2009 November
521 2009 December
609 2010 January
619 2010 February
732 2010 March
605 2010 April
736 2010 May

How do i get this into this into Google stacked column chart so that the Y-axis is No_sales, the x_axis months and the graphs key is the years. So the data is grouped by years.

I have attempted various techniques but just cant seem to nab it. I have the controller,model and view files attached.

Thanks for any help.
#2

[eluser]kiwimediapro[/eluser]
Anyone have any ideas?
#3

[eluser]vitoco[/eluser]
if you put the format/estructure that you need it get easier to help you, cause in my case i don't know the "Google stacked column" format.

Saludos
#4

[eluser]kiwimediapro[/eluser]
Yes I gues that would help. :-) It is in the attached files in the view.

Here it is:

raw_data = [['<yr1>',month1,month2, etc...],['<yr2>',month1,month2, etc...]etc...]

raw_data=[['2009',728,640,636,636,635,682,681,588,588,660,524,521],['2010',609,619,732,605,794,35]];




Theme © iAndrew 2016 - Forum software by © MyBB