I have a time and attendance SQL 2005 database
So every time some one clocks in it adds a new entry into the table with their UserID and a DateTime entry.
I have a second table with all the users details.
On a specific day, I can run a query:
SELECT *
FROM TASVR.dbo.Persons
WHERE
UserID LIKE '[0-9][0-9][0-9][0-9][0-9]'
AND UserID NOT IN
(SELECT UserID
FROM TASVR.dbo.TAData
WHERE
(
DateTime > '" . $strDate . " 00:00:00'
AND DateTime < '" . $strDate . " 12:00:00'
))
ORDER BY LName ASC
Which returns anyone who has not clocked in or anyone who has clocked in after 12 for the given date.
Now I want to run this query over a period of 2 weeks (excluding Sat and Sun) and it to return the days they were absent (or at least the days they were present) all in the form of something useful that I can play with in PHP.
So I need a loop with some exclusions. Any ideas?
Even if I just have a list of names of anyone that was absent over the time period, then I would just create another query in a PHP loop to pull those specific people's details for the period and work from there.
Update
I have managed to figure out how I am going to display when a person is absent over a date period using php arrays. Now if only I could work out how to get a list of UserIDs of the people that have been absent at least once in the range... For now, I have it checking against EVERY SINGLE PERSON!!! Which is time consuming to say the least.