Results 1 to 6 of 6

Thread: FSACARS Help

  1. Default FSACARS Help

    I am in desperate need of some help. I run Alaska Adventures - http://www.flyaka.com

    I use FSACARS and my totla hours is stuck on 838:59:59. Any help would be appreciated or if someone can share there total hours script. I have tried to get help from the FSACARS site with no luck. There forums are pretty much dead. Here is how my total hours script written. If you go to my site and look at the stats on the left you will see what I'm talking about.


    <?php

    /* Constants */
    @define ("MYSQL_CONNECT_INCLUDE", "connect_db.php"); // MySQL database connection

    /* Database connection */
    include(MYSQL_CONNECT_INCLUDE);

    $query = "SELECT SEC_TO_TIME( SUM( TIME_TO_SEC(reports.duration))) AS SUM_OF_duration FROM reports";

    $result = mysql_query($query) or die('0');

    $data = mysql_fetch_row($result);

    $sum = $data<0>;

    echo("$sum");

    php?>

    http://www.flyaka.com/ACARS/hours.php


    Eddie

  2. #2
    Join Date
    Mar 2005
    Location
    Bonners Ferry, Idaho, USA
    Posts
    2,214
    Blog Entries
    4

    Default

    Hi Eddie, that script that Karim Spinedi (airgeneva) posted in your thread at SATA Virtual seems to work great for me. (I would have posted this there but I registered 3 days ago and still haven't been activated on the forum). Anyway here's what I've found to work:
    Code:
    <?php
    
    /* Constants */
    @define ("MYSQL_CONNECT_INCLUDE", "connect_db.php"); // MySQL database connection
    
    /* Database connection */
    include(MYSQL_CONNECT_INCLUDE);
    
           $query_hours = "SELECT sum(time_to_sec(duration)) as duration_sum FROM reports";
           $result_hours = mysql_query($query_hours);
    
    	   if (mysql_numrows($result_hours) > 0) {
    	   $time1 = mysql_result($result_hours,0,"duration_sum");
    
    	   // Calcul of flight time  in  "hours" "minutes" in function of seconds
    
    	   $hourTot = $time1 / 3600;
    	   $hourTotentry = floor($hourTot);
    
    	   $minuteTot=((($hourTot - $hourTotentry) *100) *60) /100;
    	   $minuteTotentry = floor($minuteTot);
    	   if ($minuteTotentry  < 10) {
    	   $minuteTotentry  = "0".$minuteTotentry  ;
    	   }
    
    	   $time = $hourTotentry.":". $minuteTotentry. ":00";
    
    }
    
         		print "<font face=tahoma size=2 color=#000000><b>Total hours flown:</b>&nbsp;&nbsp;&nbsp;$time</font>";
    
    
    
    /* Close the database connection */
    mysql_close();
    
    php?>
    Here it is in use:
    http://www.cat-tamer.com/flightsim/f...global_hrs.php

    I'd like a script where a new pilot can enter name, email, etc and when he clicks the submit button his data gets inserted into the pilots table, he gets an email with an attached .ini file, and his log folder gets created on the server all in one fell swoop. Have you seen anything like that?

    Jim



    i7 2600K @ 4.4 gHz | GA-Z68XP-UD3-iSSD | EVGA GTX580 | 8 Gb DDR3 @ 1866 mHz | 256Gb 6Gb/sec SSD (x2) | 1Tb WD Caviar 6Gb/sec | 27" LED Monitor | W7 Pro 64

  3. #3
    Join Date
    Mar 2005
    Location
    Bonners Ferry, Idaho, USA
    Posts
    2,214
    Blog Entries
    4

    Default

    I see you got it working, you're welcome



    i7 2600K @ 4.4 gHz | GA-Z68XP-UD3-iSSD | EVGA GTX580 | 8 Gb DDR3 @ 1866 mHz | 256Gb 6Gb/sec SSD (x2) | 1Tb WD Caviar 6Gb/sec | 27" LED Monitor | W7 Pro 64

  4. Default

    Actually someone made one for me. Didn't see your post until yesterday. I am looking for a way to show the total average flight time. Any ideas?

    Eddie

  5. #5
    Join Date
    Mar 2005
    Location
    Bonners Ferry, Idaho, USA
    Posts
    2,214
    Blog Entries
    4

    Default

    Not sure exactly what you're wanting to average but this will return the average flight time of all pireps filed:
    Code:
    <?php
    
    /* Constants */
    @define ("MYSQL_CONNECT_INCLUDE", "connect_db.php"); // MySQL database connection
    
    /* Database connection */
    include(MYSQL_CONNECT_INCLUDE);
    
           $query_hours = "SELECT sum(time_to_sec(duration)) as duration_sum FROM reports WHERE fsacars_rep_url IS NOT NULL";
           $result_hours = mysql_query($query_hours);
    
    	   if (mysql_numrows($result_hours) > 0) {
    	   $time1 = mysql_result($result_hours,0,"duration_sum");
    
    	   $time2 = $time1 / 3600;
    	   }
    
    
           $query_pireps = "SELECT * FROM reports WHERE fsacars_rep_url IS NOT NULL";
           $result = mysql_query($query_pireps);
    
           $pireps = mysql_numrows($result);
    
    	   $avg1 = $time2 / $pireps;
    	   $avg = number_format ($avg1, 2, ".", "");
    
    	       print "<font face=tahoma size=2><b>Average flight length:</b> $avg hrs.</font>";
    
    /* Close the database connection */
    mysql_close();
    php?>
    "WHERE fsacars_rep_url IS NOT NULL" keeps it from factoring in the dummy flights you've used to import a pilot's hours (providing you've set the fsacars_rep_url field to NULL for those flights). Otherwise your average flight length might return 100 hrs or more.

    Here's the script in use:

    http://www.cat-tamer.com/flightsim/f...per_flight.php

    Jim



    i7 2600K @ 4.4 gHz | GA-Z68XP-UD3-iSSD | EVGA GTX580 | 8 Gb DDR3 @ 1866 mHz | 256Gb 6Gb/sec SSD (x2) | 1Tb WD Caviar 6Gb/sec | 27" LED Monitor | W7 Pro 64

  6. Default

    Jim,
    That was exactly what I was looking for. I appreciate the help.

    Eddie

Similar Threads

  1. FSACARS replacement
    By CEO_SV in forum Virtual Airlines
    Replies: 5
    Last Post: 01-15-2010, 06:10 AM
  2. FSACARS trouble (Vista)
    By CEO_SV in forum FS2004
    Replies: 1
    Last Post: 12-10-2009, 01:00 PM
  3. FSAcars w/ Windows 7
    By CXA001 in forum Virtual Airlines
    Replies: 7
    Last Post: 12-10-2009, 12:38 PM
  4. Paginating FSACARS Roster Page
    By flyalaska in forum Virtual Airlines
    Replies: 0
    Last Post: 02-08-2009, 02:01 AM
  5. FSACARS integration
    By taromva in forum Virtual Airlines
    Replies: 0
    Last Post: 05-15-2008, 05:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •