Jump to content

Pilots on external site


Henrique

Recommended Posts

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

Edited by ProSkyDesign
grammar errors
Link to comment
Share on other sites

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()

Link to comment
Share on other sites

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

Edited by ProSkyDesign
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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