Crew-Portal Posted November 1, 2007 Share Posted November 1, 2007 Lets start off by giving you my code (Well the important sections of it!): <?php /**/ # Total Time /**/ $query = "SELECT sum(hours) FROM flights ".$condition; /**/ $result=mysql_query($query); /**/ $blcktime = number_format(mysql_result($result,0)); /**/ $query = "SELECT sum(minutes) FROM flights ".$condition; /**/ $result=mysql_query($query); /**/ $blckmins = number_format(mysql_result($result,0)); echo "$blcktime:$blckmins"; ?> Okay this part works. Like if there is an entry that has 20 hours in hours table and 50 minutes in minute table it displays 20:50, but my problem is if there are more than one record (Which there will be) if the previous was still true and another record had 1:30 the total would be 21:80 but this of course is not correct addition of time. And this is not a 24 hour clock it simply displays the time someones been in a game so it can go lke 300:56 too. Now how would I get it so if the $minutes were greater than 60 and divisible by 60 it would add the correct numbers to the hours like $hours = $hours + $times_divisible; or something like that! I am okay with if..else..elseif statements but that would take forever to write. thats why I need a looping sttatement but I havent got a clue how to write it. If anyon could help I would greatly appreciate it! Like High five Appreciation! Thanx, and sorry but in my PHP book I never did understand how to loop Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted November 1, 2007 Author Share Posted November 1, 2007 Example Of This Viewable On My Webserver http://24.76.166.219/index.php?page=profile&id=1 Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 1, 2007 Share Posted November 1, 2007 instead of echo "$blcktime:$blckmins"; try $intSeconds = ($blcktime*3600)+($blckmins*60); echo floor($intSeconds/3600).":".floor($intSeconds/60)%60; Quote Link to comment Share on other sites More sharing options...
Crew-Portal Posted November 1, 2007 Author Share Posted November 1, 2007 Wow you are a WizzKid! Thanx Alot! TOPIC SOLVED!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.