An interesting challenge. In short, there is a log (TABLE log)
form:
id |NAME | DATE | PROFIT ---+-----+------------+------- 1 | BEN |'2011-01-01'| 3 2 | ANN |'2011-01-01'| 1 3 | JOY |'2011-01-05'| 7 4 | BEN |'2011-01-03'| 2 .... ? | PAUL|'2011-12-31'| 5
BEN, ANN
, etc. these are clerks. DATE
and PROFIT
- the profit they brought on that day. Important! All fields are not NULL
. id
- PRIMARY KEY AUTO_INCREMENT
.
Suppose uncle PETYA
came and said: “I want a report from 2011-01-03
to 2011-01-10
”. Approximately this type:
|'2011-01-01'|'2011-01-02'|'2011-01-03'|...|'2011-01-10' ----+------------+------------+------------+---+------------ ANN| 1 | NULL | 6 |...| NULL BEN| 3 | 2 | NULL |...| 9 .... TOM| NULL | NULL | 5 |...| 4
Those. here all the clerks are listed without repetition and exactly all the dates requested by the CHEF. Obviously, if you failed to earn that day, then the report is NULL
(or empty or  
).
Now the question is how to output this report to a table using PHP
. The names of all employees are known in advance, and dates can always be added to the end of the log. Please focus on PHP
(up to echo "<tr></tr>"
))), because for the 3rd day I can’t deal with the output functions of mysql_fetch_array
and mysql_result
.
PS He invented the task.