Ok, so to add some more detail to this.
I am currently using this code in order to get the start date of the last 8 weeks;
PHP Code:
function datefromweek ($y, $w, $o) {
$days = ($w - 1) * 7 + $o;
$firstdayofyear = getdate(mktime(0,0,0,1,1,$y));
if ($firstdayofyear["wday"] == 0) $firstdayofyear["wday"] += 7;
# in getdate, Sunday is 0 instead of 7
$firstmonday = getdate(mktime(0,0,0,1,1-$firstdayofyear["wday"]+1,$y));
$calcdate = getdate(mktime(0,0,0,$firstmonday["mon"], $firstmonday["mday"]+$days,$firstmonday["year"]));
$date = $calcdate["year"] . "-" . $calcdate["mon"] . "-" . $calcdate["mday"];
return($date);
}
for ($i=1; $i<9; $i++) {
$year=date('Y');
$week=date('W');
$week_array[]=datefromweek($year, $week, $offset);
$offset-=7;
}
This gives me my desired dates. The array looks like this:
Array ( [0] => 2009-7-20 [1] => 2009-7-13 [2] => 2009-7-6 [3] => 2009-6-29 [4] => 2009-6-22 [5] => 2009-6-15 [6] => 2009-6-8 [7] => 2009-6-1 [8] => 2009-5-25 [9] => 2009-5-18 [10] => 2009-5-11 [11] => 2009-5-4 )
So now, how would I organize my data, so I can fit the values into the appropiate date, for the appropiate item?
Essentially, what I would need is something like...
PHP Code:
<?php
$DATA = array (
ITEM 1 (
2009-7-20 => 55
2009-7-13 => 12
2009-7-06 => 167.1 )
ITEM 2 (
2009-7-20 => 11
2009-7-13 => 67
2009-7-06 => 4 )
)
etc...
?>
I am not sure how to get it formatted like this, as my output from the database after I perform some calculations looks like this on a row-by-row basis:
Item 3 --- 2009-06-29 --- 11.1
Item 5 --- 2009-06-29 --- 9000.1
Item 1 --- 2009-06-29 --- 12.5
Item 2 --- 2009-06-29 --- 357.1
Item 6 --- 2009-07-06 --- 208.3
Item 3 --- 2009-07-06 --- 11250.3
Item 1 --- 2009-07-06 --- 167.1
Bookmarks