# Pilot Hub List

**URL:** <https://forum.phpvms.net/t/pilot-hub-list/3644>\
**Category:** Development Help\
**Created:** [November 9, 2010, 9:44am UTC](https://forum.phpvms.net/t/pilot-hub-list/3644 "2010-11-09T09:44:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimitris](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@dimitris](https://forum.phpvms.net/u/dimitris)\
**Post date:** [November 9, 2010, 9:44am UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/1 "2010-11-09T09:44:56Z")

</div>

Hello !

I want to display a table with the pilots forom every hub.

For example i have a HUB the EDDF and i want to display only those pilots. Have someone a code for this ?

---

<div class="post-metadata">

**Author:** ![simpilot](https://forum.phpvms.net/user_avatar/forum.phpvms.net/simpilot/32/26_2.png) [@simpilot](https://forum.phpvms.net/u/simpilot)\
**Post date:** [November 9, 2010, 5:42pm UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/2 "2010-11-09T17:42:04Z")

</div>

To collect the data you can use the existing PilotData class -\>

```
<?php $pilots = PilotData::getAllPilotsByHub('EDDF'); ?>

```

Then you will have the $pilots variable loaded with just the pilots from EDDF and you can use it to display them in a table or whatever you would like.

---

<div class="post-metadata">

**Author:** ![dimitris](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@dimitris](https://forum.phpvms.net/u/dimitris)\
**Post date:** [November 10, 2010, 2:36pm UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/3 "2010-11-10T14:36:55Z")

</div>

hello !

thank you simpilot i try it but no results me code is :

```
<h3>Thessaloniki Airport (LGTS)</h3>
<?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?>
<table id="tabledlist" class="tablesorter" width="800" border="0">
 <tr>
   <th>Pilot</th>
   <th>Country</th>
<th>Rank</th>
 </tr>
 <tr>
   <td><?php echo ($pilots->code, $pilots->pilotid); ?></td>
   <td><img src="<?php echo Countries::getCountryImage($pilot->location);?>"
		alt="<?php echo Countries::getCountryName($pilot->location);?>" /></td>
   <td><img src="<?php echo $pilot->rankimage?>" alt="<?php echo $pilot->rank;?>" /></td>
 </tr>
</table>

```

but without any success… can you help me ?

---

<div class="post-metadata">

**Author:** ![simpilot](https://forum.phpvms.net/user_avatar/forum.phpvms.net/simpilot/32/26_2.png) [@simpilot](https://forum.phpvms.net/u/simpilot)\
**Post date:** [November 10, 2010, 2:43pm UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/4 "2010-11-10T14:43:54Z")

</div>

You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want.

```
<h3>Thessaloniki Airport (LGTS)</h3>
<?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?>
<table id="tabledlist" class="tablesorter" width="800" border="0">
   <tr>
       <th>Pilot</th>
       <th>Country</th>
       <th>Rank</th>
   </tr>
   <?php
   foreach ($pilots as $pilot) {
   ?>
       <tr>
           <td><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></td>
           <td><img src="<?php echo Countries::getCountryImage($pilot->location); ?>"
                    alt="<?php echo Countries::getCountryName($pilot->location); ?>" /></td>
           <td><img src="<?php echo $pilot->rankimage ?>" alt="<?php echo $pilot->rank; ?>" /></td>
       </tr>
   <?php
   }
   ?>
</table>

```

---

<div class="post-metadata">

**Author:** ![dimitris](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@dimitris](https://forum.phpvms.net/u/dimitris)\
**Post date:** [November 10, 2010, 2:47pm UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/5 "2010-11-10T14:47:57Z")

</div>

> You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want.
> 
> ### Thessaloniki Airport (LGTS)
> \<?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?\> \<?php foreach ($pilots as $pilot) { ?\> \<?php } ?\>
> 
> | Pilot | Country | Rank |
> | --- | --- | --- |
> | \<?php echo PilotData::GetPilotCode($pilot-\>code, $pilot-\>pilotid); ?\> | ![<?php echo Countries::getCountryName($pilot->location); ?>]() | ![<?php echo $pilot->rank; ?>]() |

You are the BEST !!! Thank you so much !!! working also if i want to show the pireps i can use this code ?

```
<?php $pireps = PirepData::getAllPirepsByHub('LGTS'); ?>

```

?

---

<div class="post-metadata">

**Author:** ![TennShadow](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tennshadow/32/16_2.png) [@TennShadow](https://forum.phpvms.net/u/TennShadow)\
**Post date:** [November 11, 2010, 6:11pm UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/6 "2010-11-11T18:11:53Z")

</div>

> You need to break up your $pilots array with a foreach loop. You have $pilots in some places and $pilot in others. You really should have the datacall back in the controller as well, not in the template but if you are using the cms/page function I see why you are doing it this way. Try this, I just did a quick clean up but it should work, you will have to style it to exactly what you want.
> 
> ### Thessaloniki Airport (LGTS)
> \<?php $pilots = PilotData::getAllPilotsByHub('LGTS'); ?\> \<?php foreach ($pilots as $pilot) { ?\> \<?php } ?\>
> 
> | Pilot | Country | Rank |
> | --- | --- | --- |
> | \<?php echo PilotData::GetPilotCode($pilot-\>code, $pilot-\>pilotid); ?\> | ![<?php echo Countries::getCountryName($pilot->location); ?>]() | ![<?php echo $pilot->rank; ?>]() |

Thanks Simpilot! I’ve always wanted a dynamic Hub page but just couldn’t figure it out. This has helped me at least get the ball rolling. I am also interested in having a list of the last 50 PIREPS for that hub as well as a list of 50 schedules leaving that hub.

I did some research on the forums and some goolging using PirepData::getAllPirepsByHub and boy did I make a mess. LOL. I spent over an hour on different things with no luck. I have to say this is fun but I just wish I could get this to stick in my head.

Anyways, thanks for getting me started on this.

Keith

---

<div class="post-metadata">

**Author:** ![simpilot](https://forum.phpvms.net/user_avatar/forum.phpvms.net/simpilot/32/26_2.png) [@simpilot](https://forum.phpvms.net/u/simpilot)\
**Post date:** [November 12, 2010, 1:05am UTC](https://forum.phpvms.net/t/pilot-hub-list/3644/7 "2010-11-12T01:05:41Z")

</div>

Thanks Keith,

try putting a

```
print_r($yourvariable);

```

right after your datacall and see what is available to you as far as field names, I believe it should be everything out of that table for PIREPS. Then you can break up the array using a foreach loop, then display what you want using

```
echo $yourvariable->fieldname

```
