3

I'm new to PHP and have the basics down but now I have a pretty big task to accomplish and really need some help getting there.

I am trying to make a system that logs when someone is absent or late for the day. So I already have a table in one database that has each users schedule with their start time, end time, the days they work, and their user id. Then there is another system that logs when they clocked in.

So what I need to do loop through the "timeclock" table for the user id, login time, and date. Then compare that to the information on my schedule table. If it finds that for example Joe Smith did not clock in on monday but he is scheduled monday it then needs to save that he was absent onto another table.

The timeclock and schedule table are on different databases on different servers, and the absent/late list would be on the same database as the schedule. Any help to at least get me pointed in the right direction would be great, thanks in advance.

1 Answer 1

1

This is a SQL question, what I understand is that you have two schemas. One with the employee info and one with the entry and leave logs. What you are probably searching for to join this two is the NATURAL JOIN and the wikipedia entry on a natural join.

Example:

SELECT * FROM logs NATURAL JOIN employees WHERE entry > schedule

Supposing both entry and schedule are simply the time of the day.

Sign up to request clarification or add additional context in comments.

4 Comments

After reading through the wikipedia page, that sounds like it should get it done...now i have to figure out how to implement it.
Well, you could add details and I can lend you a hand or if it is enough info for you to manage it by yourself an upvote and the acceptance of this answer would be appreciated.
Would love to vote up but cant until my rep is 15 im still at 11 but I will accept the answer. But talking to the network admin (the one who has me doing this) he wants me to do it all in PHP and he doesnt think the tables should be joined. So back to the drawing board I guess.
This is a query, the tables aren't modified and you simply get the two results joined and ready for more operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.