Page 1 of 1

[php+mysql]work schedule

Posted: Thu Feb 04, 2010 8:58 am
by pawciak
Hi Everybody!

I'm new here, and I'm new with programming in php. Im after programming few very simple scripts. Now, I want to develop a script - work schedule. In this script people will choose time of starting and ending their shift at work -> from tuesday to monday; I want to save this data to my mysql db ( and after that I want to save all this data to xml external file; but all in all i want to prepare now the first part of script -> saving data to db ). Form should look like that:

Code: Select all

 
 
<form action="" method="post" name="worklog">
 
<p>monday</p>
<select name="monday_start">
<option>6:00</option>
<option>7:00</option>
<option>8:00</option>
<option>9:00</option>
<option>10:00</option>
<option>11:00</option>
<option>12:00</option>
<option>13:00</option>
<option>14:00</option>
<option>15:00</option>
<option>16:00</option>
<option>17:00</option>
<option>18:00</option>
<option>19:00</option>
<option>20:00</option>
<option>21:00</option>
<option>22:00</option>
<option>OFF</option>
</select>
 
<select name="monday_stop">
<option>6:00</option>
<option>7:00</option>
<option>8:00</option>
<option>9:00</option>
<option>10:00</option>
<option>11:00</option>
<option>12:00</option>
<option>13:00</option>
<option>14:00</option>
<option>15:00</option>
<option>16:00</option>
<option>17:00</option>
<option>18:00</option>
<option>19:00</option>
<option>20:00</option>
<option>21:00</option>
<option>22:00</option>
<option>OFF</option>
</select>
 
[ ... rest of days of week ... ]
<input type="submit" name="wyslij" value="wyslij_dane">
</form>
I think the best way to create this form is to make a class am i right? OFF means a day off as you know:) After fullfilling form, and pushing the send button data will be send to my msql db. This DB contains 2 tabels:
+ users (id,username,password)
+ worklog (id,user_id,data,start_time,end_time)

Im not sure if the second table is correct. Generally, i've got a very simple login system which use the users table and after login -> users will have a form to sending data. Ive got few problems:
1) Filling this form is a reproducible activity - users will do it weekly. So how to prepare corectly this script if i want to have only the newest data from last week? I want to avoid the situation, when i DB i will have mixed data from different weeks.
2) As i said it is reproducible activity - Do i need to set up all the weeks for example 10.1.2010-16.1.2010;17.1.2010-23.1.2010 in some file etc. or is there any way to set it up in some kind of interval?
3) in one of the websites with php scripts I found a library called simpleXML which I want to use to save data from library to xml file. Can i use it do save data in xml file in my order -> list of all users divided for week days and there will be their work times in every day ( for example 6.00 AM - 2 P.M ). It is a good library for it or there is better solution? thanks for help and sorry for my noob questions, but as i said - im quite new in php world ;) cheers! Pawel

Re: [php+mysql]work schedule

Posted: Thu Feb 04, 2010 12:45 pm
by JakeJ
What you're asking for is a little much. May I suggest you try to do as much as possible and then ask when you have a specific problem.

The Tutorial section (or google) should provide you with the knowledge to send data to the database. You don't necessarily need a class in order to do that. You don't need to set up all the weeks. Use the date() function along with strtotime() functions; you can find plenty of examples for usage. And I can't be of much help with the XML since I haven't worked with it much (yet) though I have a project coming up which will utilize it.