Re: Math problems (No not high school math!)
| From: | Jason Pruim | Date: | Thu, 25 Sep 2008 15:30:48 +0000 |
| Subject: | Re: Math problems (No not high school math!) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280925@lists.php.net to get a copy of this message | ||
On Sep 25, 2008, at 11:28 AM, Jim Lucas wrote:
Jason Pruim wrote:Hi Jim, You are correct, I want it to look something like this: Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day Name | time in | timeout | total for day TOTAL FOR WEEK: XSo I'm trying to figure out how to do a little math in php to add up the number of hours that people have worked (Still on the timecard for anyone following along at home) I have it inserting time in and timeout as timestamps into a MySQL database, from there, I use a while loop to display the total hours for the day which works perfectly, now though, they want it to total for the week... I think what I need to do is create an array of my total time for the day then add that up in another loop to display the total... That seems like overkill to me though... is there a better way to do it? Here is the relevant part of the code: while ($row = mysql_fetch_assoc($result)){Doesn't seem logical to have the weekly total displayed at the end of each day. Are you wanting a subtotal of each day being added to the weekly total to be displayed next to each day? If that is the case, the just have one variable that you add each days total to that doesn't get reset when the new DAY is started.$timein = date("m/d/y h:i:s", $row['timein']); $timeout = date("m/d/y h:i:s", $row['timeout']); $totalday = ($row['timeout'] - $row['timein']); $totalday = $totalday/60/60; $totalday = round($totalday, 2); $totalweek = ?!@?#!@#?!@#!$%^!23?!@#!@#?!@#?#$&*^echo <<<ADMIN<tr> <td>{$row['Name']}</td> <td>{$timein}</td> <td>{$timeout}</td> <td>{$totalday}</td></tr>ADMIN;} echo "</table> </div> </body>";-- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.com
--Jim Lucas "Some men are born to greatness, some achieve greatness,-- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.comand some have greatness thrust upon them."Twelfth Night, Act II, Scene V by William Shakespeare