# Pilot List by Custom Field Data

**URL:** <https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669>\
**Category:** Development Help\
**Created:** [November 29, 2015, 3:29pm UTC](https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669 "2015-11-29T15:29:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LH458](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@LH458](https://forum.phpvms.net/u/LH458)\
**Post date:** [November 29, 2015, 3:29pm UTC](https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669/1 "2015-11-29T15:29:29Z")

</div>

Hello,

For my VA i want to change the pilot list to show the pilots not by all of our hubs but by an Custom Field Value. The name of this field is Status and the three possible Values are “IVAO Pilot” “Active Pilot” and “Inactive Member”. It would be great if you could help us.

Thank you,

Bastian Wagne (Cologne International VA)

---

<div class="post-metadata">

**Author:** ![ctabuyo](https://forum.phpvms.net/user_avatar/forum.phpvms.net/ctabuyo/32/767_2.png) [@ctabuyo](https://forum.phpvms.net/u/ctabuyo)\
**Post date:** [November 30, 2015, 9:17pm UTC](https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669/2 "2015-11-30T21:17:42Z")

</div>

Hello Bastian, and welcome to this forum:

In order to achieve what you are trying to do…

…1st step: YouÂ´ll have too look for the pilot\_list.tpl of your current skin, and then you will probably have an HTML table, like this one for example:

```
<table id="tabledlist" class="table table-bordered">
<thead>
<tr>
<th>Pilot ID</th>
<th>Name</th>
<th>Rank</th>
<th>VATSIM ID</th>
<th>IVAO</th>
<th>Flights</th>
<th>Hours</th>
</tr>
</thead>
<tbody>

```

So what you have to do is add a new \<th\> called Status, so like this: \<th\>status\</th\>

2n steep: Look for the php code at the bottom of the file, youÂ´ll have to add there something like this, being carefully of respecting the order of the \<th\> created before with the \<td\> on this section of the code if you know what I mean:

```
<td>
  <?php echo PilotData::GetFieldValue($pilot->pilotid, 'Status'); ?>
 </td

```

Kind regards, and let me know if it worked!

---

<div class="post-metadata">

**Author:** ![LH458](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ccd318/32.png) [@LH458](https://forum.phpvms.net/u/LH458)\
**Post date:** [December 1, 2015, 4:40pm UTC](https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669/3 "2015-12-01T16:40:05Z")

</div>

I think you’ve missunderstood me. My goal is to list the pilots by their status. Currently they are grouped by hub (All pilots for Hub XXXX), but I want to group them by this coustom field value (e.g. All IVAO-Pilots, etc.) if you know what I mean.

Bastian Wagner

---

<div class="post-metadata">

**Author:** ![ctabuyo](https://forum.phpvms.net/user_avatar/forum.phpvms.net/ctabuyo/32/767_2.png) [@ctabuyo](https://forum.phpvms.net/u/ctabuyo)\
**Post date:** [December 3, 2015, 5:53pm UTC](https://forum.phpvms.net/t/pilot-list-by-custom-field-data/10669/4 "2015-12-03T17:53:35Z")

</div>

Sorry for the delay I am really busy with some other proyects.:

Ok, letÂ´s try this, Go to:

Core-\>Modules-\>Pilots and open Pilots.php

Then, inside the public function index modify the code look like this:

```
class Pilots extends CodonModule
{
public function index()
{
$pdo = new PDO('mysql:host=$host; dbname=$database;', $user, $pass);
$stmt = $pdo->prepare('SELECT "pilotid" FROM "phpvms_fieldvalues" WHERE "value" = "IVAO Pilot"');
$stmt->execute();
$result = $stmt->fetchAll();

if(!$result) $result = array();
foreach($result as $res)
{
$this->set('title', 'IVAO Pilot');

$this->set('allpilots', $res);

$this->render('pilots_list.tpl');
}

```

P.S: Notice this is a kind of pseudo-code that I havenÂ´t had the chance to try it, so it might not work correctly at all.

Regards!
