I am kind of a novice in programming. I am trying to create an array from a MySQL table, which I will use later to create a graph in PHP/Javascript.
The entire idea is, that I want to make an array, filled with data representing every week of the year. So, an array with 52 entries (lets forget the 53'rd week which occurs sometimes).
My database:
I have 1 table in my database which I use for this:
+-------------------------+ I production I +-------------------------+ I Shift I (number) I <-ranging from 1 to 3 (different shifts people make) I Line I (number) I <-ranging from 1-8 (different 'conveyor belts') I Products I (number) I <-ranging from 0- a lot! (To be entered in a form) I Week I (number) I <-ranging from 1 to 52 +-------------------------+
Now, the idea is, that I want an array, filled with the SUM of all the products. The SUM(Products) must exist of the following:
Sum of all products per shift + line.
Shift 1, Line 1, made 10,000 products
Shift 1, Line 2, made 15,000 products
Shift 1, Line 3, made 20,000 products (etc etc)
SUM(Products)
will be all products from shift 1 to 3, and all lines 1 to 8.
So: 10,000 + 15,000 + 20,000 etc etc.
I want this total to be put inside an array, having 'week 1' as my array keys.
So for the first week you get:
$array (
"1" => // SUM(products) of week 1 (which was the 10,000 + 15,000 + 20,000 etc)
"2" => // SUM(products) of week 2
"3" => // SUM(products) of week 3
// etc.
Can I do this by adding 52 different MySQL-Queries, with the only difference WHERE week='x'?
So far I have only been experimenting with code found on the interwebz.
Any help would be greatly appreciated! :D
Greetings from Holland