Pilots on external site

How can I display the list of pilots on my external site?

I’m using  <?php include(/sytem/core/codon.config.php’); ?>  ( it is working perfectly, but I just can’t make the pilot list for my site. )

On 10/4/2019 at 4:14 PM, Henrique said:

How can I display the list of pilots on my external site?

I’m using  <?php include(/sytem/core/codon.config.php’); ?>  ( it is working perfectly, but I just can’t make the pilot list for my site. )

now you can access statics functions inside variables like:

$pilots = PilotData::getAllPilots();

and then you can iterate the variable with a foreach loop.

\<?php foreach($pilots as $pilot) { echo $pilot-\>rank; } ?\>

Please, be careful including the codon config, include this in top of the file, avoiding headers errors.

On 10/5/2019 at 5:39 PM, ProSkyDesign said:

now you can access statics functions inside variables like:

$pilots = PilotData::getAllPilots();

and then you can iterate the variable with a foreach loop.

<?php foreach($pilots as $pilot) { echo $pilot->rank; } ?>

Please, be careful including the codon config, include this in top of the file, avoiding headers errors.

Message: Invalid argument supplied for foreach()

how can i put a table there? table in echo

2 hours ago, Henrique said:

how can i put a table there? table in echo

Personally, I don’t recommend to print HTML code with php, please use something like this.

\<?php if(!$pilots) { echo 'There are no pilots!'; return; } ?\> \<table class="tablesorter"\> \<thead\> \<tr\> \<th\>Pilot ID\</th\> \<th\>Name\</th\> \<th\>Rank\</th\> \<th\>Flights\</th\> \<th\>Hours\</th\> \</tr\> \</thead\> \<tbody\> \<tr\> \<?php foreach($pilots as $pilot) { ?\> \<td\>\<a href="\<?php echo url('/profile/view/'.$pilot-\>pilotid);?\>"\>\<?php echo PilotData::GetPilotCode($pilot-\>code, $pilot-\>pilotid); ?\>\</a\>\</td\> \<td\>\<?php echo $pilot-\>firstname . ' '. $pilot-\>lastname; ?\>\</td\> \<td\>\<img src="\<?php echo $pilot-\>rankimage; ?\>" alt="\<?php echo $pilot-\>rank; ?\>" /\>\</td\> \<td\>\<?php echo $pilot-\>totalflights; ?\>\</td\> \<td\>\<?php echo $pilot-\>totalflights; ?\>\</td\> \<td\>\<?php echo Util::AddTime($pilot-\>totalhours, $pilot-\>transferhours); ?\>\</td\> \<?php } ?\> \</tr\> \</tbody\> \</table\>

Remember to declare $pilots variable first with your codon config.

17 hours ago, ProSkyDesign said:

Personally, I don’t recommend to print HTML code with php, please use something like this.

<?php if(!$pilots) { echo ‘There are no pilots!’; return; } ?> <table class=“tablesorter”> <thead> <tr> <th>Pilot ID</th> <th>Name</th> <th>Rank</th> <th>Flights</th> <th>Hours</th> </tr> </thead> <tbody> <tr> <?php foreach($pilots as $pilot) { ?> <td><a href=“<?php echo url(‘/profile/view/’.$pilot->pilotid);?>”><?php echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid); ?></a></td> <td><?php echo $pilot->firstname . ’ '. $pilot->lastname; ?></td> <td><img src=“<?php echo $pilot->rankimage; ?>” alt=“<?php echo $pilot->rank; ?>” /></td> <td><?php echo $pilot->totalflights; ?></td> <td><?php echo $pilot->totalflights; ?></td> <td><?php echo Util::AddTime($pilot->totalhours, $pilot->transferhours); ?></td> <?php } ?> </tr> </tbody> </table>

Remember to declare $pilots variable first with your codon config.

it worked, thank you very much.

1 Like

21 minutes ago, Henrique said:

it worked, thank you very much.

You’re welcome