Jump to content

hour limit?


adzie

Recommended Posts

Hi guys,

 

just changed server and established the original scripts have a few issues on the new server.

 

The script below should add together a members total hours, it does this but will not show anything over 839 hours, anything upto 839 hours is fine but over that and it just shows 839.  Manual checking the database the time should be more.  any thoughts

 

<?php error_reporting(E_ALL);


function fatimg($fat) {

                switch ($fat) {

                case "0":
                $img="fat0.gif";
                break;

                case "1":
                $img="fat1.gif";
                break;

                case "2":
                $img="fat2.gif";
                break;

                case "3":
                $img="fat3.gif";
                break;

                case "4":
                $img="fat4.gif";
                break;

                case "5":
                $img="fat5.gif";
                break;

                case "6":
                $img="fat6.gif";
                break;

                case "7":
                $img="fat7.gif";
                break;

                case "8":
                $img="fat8.gif";
                break;

                case "9":
                $img="fat9.gif";
                break;

                case "10":
                $img="fat10.gif";
                break;

                case "11":
                $img="fat11.gif";
                break;


                default:
                $img="fat0.gif";
                break;

                }

        $rtn="<img src=../images/rosterimages/".$img.">";
        return $rtn;
}


@define ("MYSQL_CONNECT_INCLUDE", "connect_db.php");    



include(MYSQL_CONNECT_INCLUDE);

$today = date("Y-m-d");
      $tyr=substr($today,0,4);
      $tmth=substr($today,5,2);
      $tday=substr($today,8,2);
      $tdate = (($tyr * 365) + ($tmth * 30) + ($tday));



$sqn=urldecode($_GET["sqn"]);
$ssql = "select * from sqns where name=\"".$sqn."\"";
$squery = mysql_query($ssql);
$sqn = mysql_fetch_row($squery);


$query = "SELECT * FROM pilots WHERE `country`='$sqn[0]' AND `active`='1' ORDER BY callsign ASC";
$result = mysql_query($query);


$number = mysql_numrows($result);

if ($number > 0) {

        print "<table>";
        print "<tr>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>CALLSIGN</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>NUMBER</b></font></td>";
        print "<td bgcolor=#ffffff width=140 height=12 align=left><font face=Arial color=#000000 size=1><b>NAME</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>RANK</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>FLIGHT TIME</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>STATUS</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>LOCATION</b></font></td>";
        print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial color=#000000 size=1><b>LAST FLIGHT</b></font></td>";
        print "</tr>";
        

        for ($i=0; $i<$number; $i++) {
                     $callsign = mysql_result($result,$i,"callsign");
                     $num = mysql_result($result,$i,"pilot_num");
                     $name = mysql_result($result,$i, "name");
                     $city = mysql_result($result,$i, "city");
                     $country = mysql_result($result,$i, "country");
                     $status = mysql_result($result,$i, "status");
                     $admis = mysql_result($result,$i, "admission_date");
                        $id = mysql_result($result,$i, "pilot_id");

                $rsql = "select * from ranks where id=\"".$city."\"";
                $rquery = mysql_query($rsql);
                $rank = mysql_fetch_row($rquery);


                     $update = "SELECT * FROM fsd_positions WHERE pnum='$num' AND type='PILOT'";
                         $last_update = mysql_query($update);
                     if  (mysql_numrows($last_update) > 0)  {
                         $new_update = mysql_result($last_update,0,"last_update");
                         $des = mysql_result($last_update,0,"des");
                         
                         $iquert = "SELECT * FROM icao WHERE icao='$des'";
                         $icaoquery = mysql_query($iquert);
                         if  (mysql_numrows($icaoquery) > 0)  {
                         $icao = mysql_result($icaoquery,0,"name");
                         }
                         else{$icao = "NO FLIGHTPLAN";
                         }
                 }
                    else { $new_update = "FSInn";
                           $status = "0";
                           $icao = " ";

                 }
                    $findreg = "SELECT * FROM fsd_positions WHERE pnum='$num' AND type='PILOT' AND last_update > DATE_SUB( NOW() , INTERVAL 5 MINUTE ) ";
                         $updatereg = mysql_query($findreg);
                     if  (mysql_numrows($updatereg) > 0)  {
                         $loc = mysql_result($updatereg,0,"ac");
                 }
                    else {
                         $loc = $icao ;
                 }


                      $acars=substr($new_update,0,10);
                      $nyr=substr($new_update,0,4);
                      $nmth=substr($new_update,5,2);
                      $nday=substr($new_update,8,2);
                      $ndate = (($nyr * 365) + ($nmth * 30) + ($nday));

                      $tdiff = $tdate - $ndate;

                       if (($status == "7") && ($tdiff > 70))
                           {
                          $query_status = "UPDATE pilots SET active = 4 WHERE pilot_num='$num'";
                           $result_status = mysql_query($query_status);
                           }
                       if (($status == "7") && ($tdiff > 59))
                           {
                          $status = "11";
                           }
                       if (($status == "7") && ($tdiff > 29))
                           {
                          $status = "9";
                           }
                       if (($status == "8") && ($tdiff < 2))
                           {
                          $status = "7";

                          $query_status = "UPDATE pilots SET status = 7 WHERE pilot_num='$num'";
                           $result_status = mysql_query($query_status);
                           }
                        if (($status == "10") && ($tdiff < 2))
                           {
                          $status = "7";

                          $query_status = "UPDATE pilots SET status = 7 WHERE pilot_num='$num'";
                           $result_status = mysql_query($query_status);
                           }

                $query_hours = "SELECT sec_to_time(sum(time_to_sec(t2.duration))) AS duration_sum FROM pilots t1, pilot_reports t2 WHERE t1.pilot_num='$num' AND t1.pilot_num=t2.pnum";
                    $result_hours = mysql_query($query_hours);

                    if (mysql_numrows($result_hours) > 0) {
                        $time = mysql_result($result_hours,0,"duration_sum");
                }




                     print "<tr>";
                     print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000>$callsign</font></td>";
                     echo '<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000><a href="../fsinn/pilot_log.php?cs='.$num.'">'.$num.'</a></font></td>';
                     print "<td bgcolor=#ffffff width=140 height=12 align=left><font face=Arial size=1 color=#000000>$name</font></td>";
                     print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000><img src=\"../images/ranks/".$rank[2]."\"></font></td>";
                     print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000>$time</font></td>";
                     print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000>".fatimg($status)."</font></td>";
                     print "<td bgcolor=#ffffff width=90 height=12 align=left><font face=Arial size=1 color=#000000>$loc</font></td>";
                     print "<td bgcolor=#ffffff width=73 height=12 align=left><font face=Arial size=1 color=#000000>$acars</font></td>";
                     print "</tr>";
                     

        }
        
        print "</table>";
}




mysql_close();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.