Soldato
i think i've just over complicated things for myself, but i'm struggling to figure out the way to store this in a php array.
essentially i am trying to display the total hours worked by shift staff, broken down by week. This is showing just 1 staff member at a time.
the data that is stored in a mysql database is the date + hours worked.
I first grab all the dates for x staff member, going back 12 weeks from todays date.
using a php while loop for each entry, I check what week number of the year that date is within.
I want to do the following:
if it's the same week as the last entry, add those hours to the total hour count for that week in an array and then store the date and hours so that later I can break down the array to show something like this.
Week 43 - Total Hours 7
12/10 - 4 hours
11/10 - 3 hours
Week 42 - Total hours 20
09/10 - 10 hours
06/10 - 6 hours
05/10 - 4 hours
Week 40 - Total Hours 2
22/09 - 2 hours
etc etc.
I just can't figure out how to store this in an array. The week isn't guaranteed to be worked within, and the amount of entries per week is different each week too.
I know i could just display the data as I do the while loop, however i want the count of total hours above the date/hours lines.
essentially i am trying to display the total hours worked by shift staff, broken down by week. This is showing just 1 staff member at a time.
the data that is stored in a mysql database is the date + hours worked.
I first grab all the dates for x staff member, going back 12 weeks from todays date.
using a php while loop for each entry, I check what week number of the year that date is within.
I want to do the following:
if it's the same week as the last entry, add those hours to the total hour count for that week in an array and then store the date and hours so that later I can break down the array to show something like this.
Week 43 - Total Hours 7
12/10 - 4 hours
11/10 - 3 hours
Week 42 - Total hours 20
09/10 - 10 hours
06/10 - 6 hours
05/10 - 4 hours
Week 40 - Total Hours 2
22/09 - 2 hours
etc etc.
I just can't figure out how to store this in an array. The week isn't guaranteed to be worked within, and the amount of entries per week is different each week too.
I know i could just display the data as I do the while loop, however i want the count of total hours above the date/hours lines.