I have entries for each day as a clock on / off. I would like to show all days of the week of the week and show days, even if there is no data in this day.
Example:
Monday 2015-05-04 - 2015-05-04 10:30:00 - 2015-05-04 15:45:34 Tuesday 2015-05-05 - 2015-05-05 08:43:23 - 2015-05-05 17:18:13 Wednesday 2015-05-06 - 2015-05-06 09:03:12 Thursday 2015-05-07 0 Entries Friday 2015-05-08 0 Entries
The DB schema looks like this:
id | user_id | punch_time | punch_status
Ideally, I would like to be able to change the date provided by MySQL to any timestamp, and it will show the days and results this week.
Thanks: D
NEW Any ideas why this doesn't work to get days when there are no entries?
SELECT * FROM punch_clock, calendar_table WHERE calendar_table.dt = DATE(punch_clock.punch_time) && calendar_table.week_num = $week && calendar_table.y = $year ORDER BY punch_clock.punch_time
New request
SELECT * FROM punch_clock LEFT JOIN calendar_table ON calendar_table.dt = DATE(punch_clock.punch_time) WHERE calendar_table.week_num = 18 && calendar_table.y = 2015;
source share