Pilot List

I would like the list of pilots of my virtual airlines do not show inactive pilots, removed or banned.

In my database is as follows .

<?php

if($userinfo->retired == 0)

echo ‘Active’;

elseif($userinfo->retired == 1)

echo ‘Inactive’;

elseif($userinfo->retired == 2)

echo ‘Banned’;

elseif($userinfo->retired == 3)

echo ‘On Leave’;

?>

My pilots_list.tpl

<?php echo $page_htmlhead; ?>
<body>
<?php Template::Show('core_navigation.tpl'); ?> <!-- /. main-header -->

   <!-- /. Carousel -->
   <div class="page-acars text-center">
 <div class="container zoomIn animated">

  <h1 class="page-title"> TRIPULANTES <span class="title-under"></span></h1>
 </div>
</div>
   <?php
if(!$allpilots)
{
 echo 'There are no pilots!';
 return;
}
?>
<table id="tabledlist" class="table table-style-1">
<thead>
<tr>
<th>Piloto</th>
<th>Nome</th>
<th>Rank</th>
   <th>VATSIM ID</th>
<th>IVAO</th>
<th>Vôos Realizados</th>
<th>Horas</th>
</tr>
</thead>
<tbody>
<?php
foreach($allpilots as $pilot)
{
/*
 To include a custom field, use the following example:
 <td>
  <?php echo PilotData::GetFieldValue($pilot->pilotid, 'VATSIM ID'); ?>
 </td>
 For instance, if you added a field called "IVAO Callsign":
  echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO Callsign'); 
 */

 // To skip a retired pilot, uncomment the next line:
 //if($pilot->retired == 1) { continue; }
?>
<tr>
<td width="1%" nowrap><a href="<?php echo url('/profile/view/'.$pilot->pilotid);?>">
  <?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid)?></a>
</td>
<td>
 <img src="<?php echo Countries::getCountryImage($pilot->location);?>"
  alt="<?php echo Countries::getCountryName($pilot->location);?>" />

 <?php echo $pilot->firstname.' '.$pilot->lastname?>
</td>
<td><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
   <td><?php echo PilotData::GetFieldValue($pilot->pilotid, 'VATSIM'); ?></td>
   <td><?php echo PilotData::GetFieldValue($pilot->pilotid, 'IVAO'); ?></td>
<td><?php echo $pilot->totalflights?></td>
<td><?php echo Util::AddTime($pilot->totalhours, $pilot->transferhours); ?></td>
<?php
}
?>
</tbody>
</table>
<?php Template::Show('footer.tpl'); ?>
   <!-- main-footer -->
   <!-- Scripts -->
   <!-- jQuery -->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
   <script>window.jQuery || document.write('<script src="<?php echo SITE_URL?>/lib/skins/golv/assets/js/jquery-1.11.1.min.js"><\/script>')</script>
   <!-- Bootsrap javascript file -->
   <script src="<?php echo SITE_URL?>/lib/skins/golv/assets/js/bootstrap.min.js"></script>
   <!-- owl carouseljavascript file -->
   <script src="<?php echo SITE_URL?>/lib/skins/golv/assets/js/owl.carousel.min.js"></script>
   <!-- Template main javascript -->
   <script src="<?php echo SITE_URL?>/lib/skins/golv/assets/js/main.js"></script>
   <script src="<?php echo SITE_URL?>/lib/skins/golv/assets/js/modernizr-2.6.2.min.js"></script>
   </body>

As you can see, in the file you pasted it has the following commented:

// To skip a retired pilot, uncomment the next line:
//if($pilot->retired == 1) { continue; }

You will have to uncomment it and update it accordingly in order to include the rest of the retired values.

It worked, thank you

The only thing I had to do and add the line.

//To skip a retired pilot, uncomment the next line:
if($pilot->retired == 1) { continue; }
if($pilot->retired == 2) { continue; }

I am basically pretty happy that you managed to do that on your own. Great!

Another doubt,

I use this code to count the number of registered pilots.

It would be possible to count only active crew?

<?php echo StatsData::PilotCount(); ?>