Jump to content

TouchdownStats 1.0


simpilot

Recommended Posts

  • 3 months later...

I need your help guys!!

I use the below code for the landing statistics, in order to show only landing below 200ft/min, but I want to exclude landings with rate lower than -100ft/min.

How can I do that?

-----------------

class TouchdownStatsData extends CodonData {

public static function get_all_stats() {

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate > '-200'

ORDER BY landingrate DESC";

return DB::get_results($query);

}

---------------------

Link to comment
Share on other sites

  • 1 month later...
  • 6 months later...
  • 4 months later...

Hey Simpilot,

I was wondering if it's possible to show the average landingrate for the year 2010 and for this year, 2011 ?

All the best wishes by the way!!

Regards

Lucas

When I want to show the airline average landing rate it only shows the text NaN.

I use phpvms 5.5.

Aoed anyobe know how to fix this?

Rick

Link to comment
Share on other sites

  • 5 months later...
  • 5 months later...

I tried some code but got this :

Fatal error: Cannot redeclare TouchdownStatsData::pilot_stats() in /storage/ssd5/341/1107341/public_html/core/common/TouchdownStatsData.class.php on line 99

I had used:

public function pilot_stats($pilotid)   {
       $query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
                   WHERE landingrate < '0'
                   AND pilotid = '$pilotid'
                   ORDER BY landingrate DESC";

       return DB::get_results($query);
   }

   public function pilot_average($pilotid) {
       $stats = self::pilot_stats($pilotid);
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }

   public function airline_average() {
       $stats = self::get_all_stats();
       $total = 0;
       $count = 0;

       foreach ($stats as $stat)
           {
           $total = $total + $stat->landingrate;
           $count++;
       }
       $average = $total / $count;

       return $average;
   }

I'm sure I'm not redeclaring

@servetas

Edited by thefiercepilot
Link to comment
Share on other sites

Guest lorathon
public static function get_landing_average($pilotid)
    {
        $sql = 'SELECT (SUM(landingrate) / COUNT(pirepid)) as avg FROM `' . TABLE_PREFIX . 'pireps`
                   WHERE landingrate < 0
                   AND pilotid = ' . $pilotid . '
                   ORDER BY landingrate DESC';
        
        $res = DB::get_row($sql);        
        return $res->avg;
    }
    

 

 

Use the above and let MySql do the work.  No need to pull all the extra data not loop through the results..  The error you are getting is coming from redeclaring the same method twice

 

Quote

Cannot redeclare TouchdownStatsData::pilot_stats()

 

Link to comment
Share on other sites

15 hours ago, lorathon said:

public static function get_landing_average($pilotid)
    {
        $sql = 'SELECT (SUM(landingrate) / COUNT(pirepid)) as avg FROM `' . TABLE_PREFIX . 'pireps`
                   WHERE landingrate < 0
                   AND pilotid = ' . $pilotid . '
                   ORDER BY landingrate DESC';
        
        $res = DB::get_row($sql);        
        return $res->avg;
    }
    

 

@lorathon 2 things-

  • Where do I put this code
  • Which variable contains the pilot's individual landing rate?

I'm guessing it's $res->avg?

Link to comment
Share on other sites

Guest lorathon

You should but this into a class file under common.  Doesn't matter where but it should be logical.  Perhaps make your own class file.  And the method returns the average as a double/float.  No need to add a parameter.  

 

$avg = self::get_landing_avgerage($pilotid);
echo $avg;

 

Change the "self" to the name of the class file.

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...
  • 1 year later...

Hello, I would like to display the smoothest landing ever in a field on my stats page. Does anyone know how?
 

This one is working to show the VAs average landing rate:

 

<?php echo ''.round(TouchdownStatsData::airline_average('airline'), 0); ?>

 

How can I modify it to show the best landing rate? Thanks

Edited by md82
Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...