Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. <?php
  2. function syndicate_flight_time($cxn) {
  3.  
  4. $Syndicate = $_SESSION['Syndicate'];
  5. $sql = "SELECT Landing, Take_Off FROM flight_log WHERE Syndicate_Name = '$Syndicate'";
  6. $result = mysqli_query($cxn,$sql)
  7.     or die ("Can't collect Group Take Off and Landing times");
  8.     while($row = mysqli_fetch_assoc($result)) {
  9.         $difference = (strtotime($row['Landing']) - strtotime($row['Take_Off']));
  10.         $total_diff += $difference;
  11.         $hours = floor($difference/60/60); // rounds the hours to the nearest hour.
  12.         $minutes = (($difference - ($hours * 60 * 60))/60); // rounds the remainder of the hours to the nearest minutes.
  13.         $time = $hours.":".$minutes; // puts a : between the hours and minutes.
  14.         echo '<br />'.$time;
  15.     }
  16. }
  17.  
  18. $total_hours = floor($total_diff/60/60); // rounds the hours to the nearest hour.
  19.         $minutes = (($total_diff - ($total_hours * 60 * 60))/60); // rounds the remainder of the hours to the nearest minutes.
  20.         $total_time = $hours.":".$minutes; // puts a : between the hours and minutes.
  21.  
  22. echo "total time:".$total_time;
  23.  
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement