![]() |
My first PHP project
Hey guys, i got a few question that i hope to get answered here so i hope i don't take too much of you time :)
basically this would be my first php "project" if you can even call it that :) just as a side note my php coding knowledge is basic at most and i'm still learning... The Theory part: I wish to make a page that tracks the work time of several people and displays some information about it in real time on the same page. The practical part: 2 buttons - Start and end work day. that allow me to start the counting the how much time has passed from the moment the work day started 1 Text field + add button - to be able to add works before and during the work day (if some one for example joined mid way. 1 table to display all the data. Now for the questions: How should i go about making this? can this be done with php by it self or do i need to use something like AJAX? will i need a MySQL database? thank you in advance Vartan |
Depends - I would suggest using a mysql database but if you dont have that you just need to:
1. Use something to identify the user (a cookie perhaps) 2. Store the start and end time in a file when the buttons are clicked you can use a php function to get the time on the host server I'd use mysql if i was you but what you are suggesting sounds pretty straight forward. |
was hoping to get some more input on this...
|
You can probably, do it entirely with PHP. Having a button you click which creates a row in your database like:
[ID: 1][Start: 1257443698][End: /Empty/] When you click the button again, it would put the end time on the newest entry (one with highest id, or you could take the one with the most recent "Start): [ID: 1][Start: 1257443698][End: 1257443720] From there's it's pretty easy to calculate the difference. :) However, this method is not really awesome. It's more cool to be able to follow it "live", so you can always see for how long you worked. Like a stopwatch. You would need some Javascript for this. It could be done like this: Click Start. Begins counting in seconds.. Click Stop. AJAX which puts the session into the database, i.e.: [ID: 1][Date: 1257443698][Time(Seconds): 732] From there it's also pretty easy to play with! :) I'm not entirely sure what you mean by the other ones, but I hope above can work out for you! The code should be pretty simple, and you learn best by doing it yourself, and then get support here. |
Thought I would throw your way some good reference material. If you don't know about php.net look them up and then do a search for the date() time() mktime() and strtotime() functions. And as a database is needed you can look up the mysql functions. They have tons of examples and user input, for all the php functions, that can be of great help if your just getting started.
Even after 10+ year of web design I always am looking things up on their site. Also I hope your web host has phpmyadmin for you to use as it will make the initial setup of the MySQL data base a breeze as well it has some nice features that may help you learn to work with MySQL. After that google, the number of times I have searched for "php somefunction" to find good examples of how to use some functions is innumerable. As far as using AJAX, I would say if your not proficient with both PHP and Javascript and debugging them then steer away from it for now. What your trying to do is fairly straight forward. I believe my first php was of a similar nature. I think as recent as a few months ago I used that script (obviously updated for php changes). After looking up those functions and you have something as far as working code that we can look at I am sure many here can help you in much more detail. |
| All times are GMT. The time now is 10:14 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0