Jump to content
simpilot

TouchdownStats 1.0

Recommended Posts

Looks like you have a server using php 5.4 or newer. You will have to change

public function get_stats_by_cur_month()

to

public static function get_stats_by_cur_month()

Share this post


Link to post
Share on other sites

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);

}

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

Share this post


Link to post
Share on other sites

There are a command, is Between if I dont remember bad.

WHERE landingrate BETWEEN -200 AND -100;

Thank you ARV187, it works like a charm..!!

Share this post


Link to post
Share on other sites

Hello Guys,

I need help about this module here :D.. On the attatced link, you can see that i was able to get the text blue, but what i want is to have the background where there are written Pilot, Aircraft an that stuff to be blue an the text a bite larger, can anyone tell me how to do that?

http://prntscr.com/bw735y

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

I use phpvms 5.5.

Does anyone know how to fix this?

Rick

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

Edited by TAV1702

Share this post


Link to post
Share on other sites

Which average value do you want? Airline average? Pilot Average? What is the period of the calculation? Alltime airline average for example?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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()

 

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×