Txmmy83 Posted February 26, 2015 Report Share Posted February 26, 2015 have question don't know if it was already asked by someone and answered is there a a possibility (function) to count all enabled aircraft by ICAO type and is there a possibility to output all registrations of the same? best regards, Thomas Quote Link to comment Share on other sites More sharing options...
freshJet Posted February 26, 2015 Report Share Posted February 26, 2015 function countAircraftByICAO($icao){ $sql = "SELECT COUNT(id) AS count FROM phpvms_aircraft WHERE icao='$icao' AND enabled='1'"; $result = DB::get_row($sql); return $result->count; } You can put that in OperationsData.class.php. That will get the count. If you want to display any fields then use this: function getAircraftByICAO($icao){ $sql = "SELECT * FROM phpvms_aircraft WHERE icao='$icao' AND enabled='1'"; return DB::get_results($sql); } Example usage: <?php $icao = 'A320'; $count = countAircraftByICAO($icao); $aircraft = getAircraftByICAO($icao); echo "There are $count aircraft <br/>"; foreach($aircraft as $item){ echo $item->registration.'<br />'; } ?> 1 Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted February 26, 2015 Author Report Share Posted February 26, 2015 where in the OperationsData.class.php should I post that? Quote Link to comment Share on other sites More sharing options...
freshJet Posted February 27, 2015 Report Share Posted February 27, 2015 core/common. Be aware though that this will be overwritten in updates, you're probably best creating a new class file first, even if it is messy and annoying. Quote Link to comment Share on other sites More sharing options...
Sava Posted February 27, 2015 Report Share Posted February 27, 2015 <?php $icao = 'A320'; $count = countAircraftByICAO($icao); $aircraft = getAircraftByICAO($icao); .... Actually, you'll be calling the method like this: OperationsData::countAircraftByICAO($icao) - note the OperationsData:: part. Quote Link to comment Share on other sites More sharing options...
freshJet Posted February 27, 2015 Report Share Posted February 27, 2015 What Sava said. Have been doing non-phpVMS stuff lately without the use of classes. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.