dtyson2000 Posted January 1, 2013 Share Posted January 1, 2013 Happy New Year, phpfreaks! So I have a client that basically wants to see how many times THIS week (always in the present) his users are logging in. There's no real need to store any data. He just wants to see a current number for the current week he happens to be checking it in. So for a short time every week (starting at midnight Mondays) the counts will reset. I haven't moved beyond the "thinking about it" phase yet and before I do I wanted to check with you to see if my thoughts make sense. Here's how I see it playing out: 1) obtain and set a variable for the current week of the year. 2) query database and count login dates (YYYY-MM-DD) that fall in that week per userid. 3) output user names and the number. Do you see any real hurdles here with comparing the login dates to the week number? And do those three steps seem to be in line with what most of you would do? Thanks for reading! Quote Link to comment Share on other sites More sharing options...
devilsvein Posted January 1, 2013 Share Posted January 1, 2013 yeah each time they log in, $variable++ I would also use a cron and every sunday night email someone the counter from variable, and then reset variable to 0 for next weeks count Quote Link to comment Share on other sites More sharing options...
dtyson2000 Posted January 1, 2013 Author Share Posted January 1, 2013 Thanks, devilsvein... The cron job makes perfect sense. Hadn't thought of that. Good call. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted January 1, 2013 Share Posted January 1, 2013 I would not reset any counters, nor is there a need to. I would create a table containing the userID and the loginTime (DATETIME). Then everytime someone logs in, you insert a row to this table. You can easily query the table for a count by user where the loginTime is between the start and end time values for the week. In my experience, about 15 minutes after you hand the first report to the boss, he will say; "you know what, I just want to see this at the end of the month" --- or something like that with some other date range. By logging the logins, you can provide just about any report he asks for. --- "Give me the counts by user of those that logged in on the weekends" (i.e. who are my hard workers?). And, don't just give him each report he asks for. Tell him it will take a day or two, and then give it to him first thing in the morning. If you do it right away, people start expecting immediate results, and soon the world will learn that computer programmers are not really as vital as everyone thinks, because they will believe everything is easy, and you will ruin all of our lives. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.