Jump to content

Recommended Posts

Posted

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

Posted

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 />';
}
?>

  • Like 1
Posted

<?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.

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...