Re: Re: Math problems (No not high school math!)
| From: | Jason Pruim | Date: | Thu, 25 Sep 2008 15:28:46 +0000 |
| Subject: | Re: Re: Math problems (No not high school math!) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-280924@lists.php.net to get a copy of this message | ||
On Sep 25, 2008, at 11:24 AM, Jason Pruim wrote:
On Sep 25, 2008, at 11:19 AM, Nathan Rixham wrote:Per an e-mail I just received suggesting that it may be wise to include the select SQL here it is: $sql = "SELECT * fromJason Pruim wrote:Actually where this is displayed, it is just a display portion, but when I do the insert here is my SQL: switch ($_GET['opt']){ case "signin"; //$sqlopt = "INSERT INTOSo 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)){sounds like a mysql job.. whats the SQL?$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 PruimRaoset Inc. Technology Manager MQC Specialist 11287 James St Holland, MI 49424 www.raoset.com japruim@raoset.comtimeStore('timein', 'timeout', 'empID') VALUES('{$timenow}', 'NULL', '{$auth['empID']}')"; $sqlopt = "INSERT INTOtimeStoreVALUES(\"{$timenow}\", \"NULL\", \"{$_SESSION['userInfo']['empID']}\", \"\", \"{$_SESSION['userInfo']['fullname']}\")"; break; case "signout"; $sqlopt = "UPDATEtimeStoreSETtimeout=\"{$timenow}\" WHEREempID=\"{$_SESSION['userInfo']['empID']}\" ANDtimeout=\"NULL\""; break; } if(isset($_GET['opt'])){ mysql_query($sqlopt) or die("sqlopt failed: " .mysql_error()); echo "<BR>SQL OPT: ".$sqlopt."<BR>"; header("Location: timecard.php"); echo "BReaking at opt get"; } Yes I know it's ugly with all the escaping but I'm working my way through that :P
timestore order by empID";
$row[]= mysql_query($sql) or die("Could not perform query: " . mysql_error());
$result = $row[0];
--
Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
11287 James St
Holland, MI 49424
www.raoset.com
japruim@raoset.com