php - How to calculate total hours and minutes in a week of an employee -


I ask to get an employee's date and time from the database. Then I am calculating the total hours and minutes working in one day. At present I am stuck at a point where I need to calculate the total hours that an employee has worked in one week. Please help, how do I calculate total hours and minutes in an week by an employee.

Code

  & lt; Php $ Sql ​​= "SELECT * from records where record_state = 'expired' and record_crited & gt; DATE_SUB ('' 2014-10-19 ', 7-day interval)"; $ Query = $ db- & gt; SELECT ($ sql); ? & Gt; & Lt; Width of table = "39%" range = "1" & gt; & Lt; Tbody & gt; & Lt; TR & gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt; Strong & gt; Day & lt; / Strong> & Lt; / Td> & Lt; Td style = "padding: 8px;" & Gt; & Lt; Strong & gt; Total hours & lt; / Strong> & Lt; / Td> & Lt; / TR & gt; & Lt ;? Php $ tally = ""; Forex Currency ($ db-> FETCH_OBJECT () as the $ line) {$ record_sign_in = $ row- & gt; Record_sign_in; $ Record_sign_out = $ line-> Record_ign_outout; $ Record_created = $ row-> Record_redited; $ Time1 = Date ("H: I", Stratom ($ record_sign_in)); $ Time2 = Date ("H: I", Stratom ($ record_sign_out)); $ Record_created = Date ("l", Stratom ($ record_created)); $ Day = $ record_created; List ($ hour, $ min) = explosion (':', $ 1 time); $ StartTimestamp = Mk Time ($ Hours, $ Minutes); List ($ hour, $ min) = explosion (':', $ time2); $ Endimestamp = am time ($ hour, $ min); $ Sec = $ endemstamp - $ starstampstamp; $ Min = ($ sec / 60)% 60; $ Hour = floor ($ sec / (60 * 60)); $ Match = "what to do here?"; ? & Gt; & Lt; TR & gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt ;? Php echo $ day; ? & Gt; & Lt; / TD & gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt ;? Php ek $ hours; ? & Gt; Hours & lt ;? Php echo $ min; ? & Gt; Minute & lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; TR & gt; & Lt; Td style = "padding: 8px;" & Gt; Total & lt; / Td> & Lt; Td style = "padding: 8px;" & Gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

How the view table looks.

Enter image details here

OK, you can start by removing lots of unnecessary intermediate variables and then do whatever you want to do $ Add the second to $ match each time and then $ tally minutes and seconds, such as where you might already be each day.

  & lt ;? Php $ sql = "Select" from records where record_state = 'expired' and record_created & gt; DATE_SUB ('2014 -10-19', interval 7 days) "; $ $ = $ db-> SELECT ($ sql);? & Gt; & lt; table width =" 39% "limit =" 1 "& Gt; & lt; tbody & gt; & lt; tr & gt; & lt; td style =" padding: 8px; "& gt; & lt; strong & gt; day & lt; / strong & gt; & Lt; / td & gt; & lt; td style = "padding: 8px;" & gt; & lt; strong & gt; total hours & lt; / strong & gt; & lt; / td & gt; Lt; / TR & gt; Php $ tally = 0; Foreign currency ($ dB-> FETCH_OBJECT () as the $ line) {$ time1 = date ("H: i", strotman ($ Line-> Record_sign_in); $ Time2 = date ("h: i", strotom ($ line-> record_us List ($ hour, $ min) = explosion (':', $ 1 time); $ StartTimestamp = Mk;); $ date = date ("L", strotom ($ line-> record_kited) Time ($ hour, $ min); list ($ hour, $ min) = explosion (':', $ time2); $ interimstamp = am time ($ hour, $ min); $ sec = $ endemstamp - $ startstartstamp; $ Minute = ($ seconds / 60)% 60; $ hours = floor ($ sec / (60 * 60)); $ Tal = + $ sec; ? & Gt; & Lt; TR & gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt ;? Php echo $ day; ? & Gt; & Lt; / TD & gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt ;? Php ek $ hours; ? & Gt; Hours & lt ;? Php echo $ min; ? & Gt; Minute & lt; / TD & gt; & Lt; / TR & gt; & Lt ;? Php}? & Gt; & Lt; TR & gt; & Lt; Td style = "padding: 8px;" & Gt; Total & lt; / Td> & Lt ;? Php $ min = ($ tal / 60)% 60; $ Hour = floor ($ clap / (60 * 60)); ? & Gt; & Lt; Td style = "padding: 8px;" & Gt; & Lt ;? Php ek $ hours; ? & Gt; Hours & lt ;? Php echo $ min; ? & Gt; Minimum & lt; / Td> & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -