I am using the following code to build a Google Chart, to pull in all of entries in a MySQL table corresponding to the Week Numbers in a year. At the moment the Week Numbers st
WEEK(date[mode]);
date = a date value.
mode = An integer indicating the starting of the week.
The default arugment is 0 which is sunday, setting this to 1 will be monday, 2 tuesday and so on.
week(date,1);
For it to work in your code, you should be able to change the query to:
"SELECT Sum(Due) FROM patient_sessions WHERE Type='Session' AND Week(Date,1)=$i"
However, I think I could go one step further and use the GROUP BY to make one sql call, and then iterate over the results;
"SELECT Week(Date,1), SUM(DUE) FROM patient_sessions WHERE Type='Session' GROUP BY Week(Date,1)"
Alternatively, you might need to use WEEK(Date,2) depending on how you want to handle weeks that span between years.