Live flight Count

Hi,

I’m not the best at coding but I would like to know if anyone knows a function that will count all live flight from the acars db and put it in a number. For example if the acars map shows 6 flight I would like the function to show 6

Thanks 

Hi,

If you send me a pm on here I could send you the code or even program your own customised page (for free of course). Just send me the details

Yours,

Tim

PM sended

For other users:

Lanoush did it a different way himself but if you want to implement it into your ACARSData class you can use this.

if you want to implement it into your ACARSData you can add this to your ACARSData.class.php

public static function getLiveFlightCount($cot = '') { // make sure its not using flights that havent been updated by using cutoff time $cutofftime = (empty($cutofftime)) ? Config::Get('ACARS\_LIVE\_TIME') : $cot; //ternary operator instead of if argument to reduce lines $sql = 'SELECT COUNT(\*) as total FROM ' . TABLE\_PREFIX . 'acarsdata'; $sql .= ($cutofftime !== 0) ? ' WHERE DATE\_SUB(NOW(), INTERVAL ' .$cutofftime .' MINUTE) \<= `lastupdate`': ''; $result = DB::get\_row($sql); return $result-\>total; }

then on any page you could use 

echo ACARSData::getLiveFlightCount();

or you could of course add it to any of your pages as a variable in the module itself:

$this-\>set('liveFlightCount',ACARSData::getLiveFlightCount()); // on the page then you could do: echo $liveFlightCount;

 

1 Like