Jump to content

Top pilots


Tameem

Recommended Posts

TopPilotData::top_pilot_hours($month, $year, 5) ; 

This likely gives you an array of the top 5. So i guess that is why you cant echo it.

You need to put it in a foreach loop in order to echo it.

Its just a guess i'm not using the toppilot module.

I didn't get it please explain

Link to comment
Share on other sites

  • Administrators

<?php echo TopPilotData::top_pilot_hours($month, $year, 5) ; ?>

This code simply returns an array with the information from the database, you need to use it to build a table or list group if that is what you are trying to do. You also need to assign values to the $month and $year variables.

You may just be wanting to link to tthe main page - mysite.com/index.php/toppilot

There are instructions for the module here -> http://forum.phpvms....-10/#entry14824

Link to comment
Share on other sites

OK first thank you.

i used this code

<?php
$month = date("m");
$year = date("Y");
$pilot= TopPilotData::top_pilot_hours($month, $year, 1) ;
foreach ($pilot as $top) {
       echo '<tr>';
       echo '<td>'.$top->hours.'</td>';
       echo '</tr>';
   }
?>

but it turns to

PHP Error Message

warning: invalid argument supplied for foreach() in frontpage_main.tpl

Link to comment
Share on other sites

  • Administrators

OK first thank you.

i used this code

<?php
$month = date("m");
$year = date("Y");
$pilot= TopPilotData::top_pilot_hours($month, $year, 1) ;
foreach ($pilot as $top) {
echo '<tr>';
echo '<td>'.$top->hours.'</td>';
echo '</tr>';
}
?>

but it turns to

PHP Error Message

warning: invalid argument supplied for foreach() in frontpage_main.tpl

Have you installed the sql file?

Is there any data in the table?

Does the VA have any flights for the current month?

Link to comment
Share on other sites

First thank you Simpilot.

I think that The sql file isn't installed probably.

also please can u give me the method that pulls the records.

and the foreach gives me invalid argument supplied for foreach()

So please i want the argument supplies for the foreach loop

Link to comment
Share on other sites

Using echo to show that data is not going to work, you need to use the method described in the instructions as you have started to do in the post above.

Have you installed the sql file?

Is there any data in the table?

Does the VA have any flights for the current month?

Thank you soooooooo much

this code worked

<?php
$month = date("m");
$year = date("Y");
$pilot = TopPilotData::top_pilot_hours($month, $year, 5);
foreach ($pilot as $top) {
    $pilot = PilotData::GetPilotData($top->pilot_id);
    echo '<tr>';
    echo '<td>'.$pilot->firstname.' '.$pilot->lastname.' - '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).'</td>';
    echo '<td>'.$top->hours.'</td>';
    echo '</tr>';
   }
?>

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

Not quite sure if it matters but here is what i use...it has some styling you can change. What is different about my code is that it shows the TOP PILOTS by flights and display the amount of flights

Feel free to use it!

<?php 
$month = date("m");
$year = date("Y");
   $topflights = TopPilotData::top_pilot_flights($month, $year, 5);
   echo '<table  cellpadding="0px"><tr><td width="100%" valign="top">';
   echo '<table class="datatable" width="100%" style="background-color:#FFF">';
   echo '<tr bgcolor="#e01933">';
   echo '<th><font color="white">Pilot</font></th>';
   echo '<th><font color="white">Flights Flown</font></th>';
   echo '</tr>';

   foreach ($topflights as $top) {
       $pilot = PilotData::GetPilotData($top->pilot_id);
       echo '<tr align="center" valign="middle">';
       echo '<td>'.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
       echo '<td>'.$top->flights.'</td>';
       echo '</tr>';
   }

   echo '</table>';
   echo '</table>';


?>
<?php {
}
?>

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

Not quite sure if it matters but here is what i use...it has some styling you can change. What is different about my code is that it shows the TOP PILOTS by flights and display the amount of flights

Feel free to use it!

<?php
$month = date("m");
$year = date("Y");
$topflights = TopPilotData::top_pilot_flights($month, $year, 5);
echo '<table cellpadding="0px"><tr><td width="100%" valign="top">';
echo '<table class="datatable" width="100%" style="background-color:#FFF">';
echo '<tr bgcolor="#e01933">';
echo '<th><font color="white">Pilot</font></th>';
echo '<th><font color="white">Flights Flown</font></th>';
echo '</tr>';

foreach ($topflights as $top) {
$pilot = PilotData::GetPilotData($top->pilot_id);
echo '<tr align="center" valign="middle">';
echo '<td>'.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
echo '<td>'.$top->flights.'</td>';
echo '</tr>';
}

echo '</table>';
echo '</table>';


?>
<?php {
}
?>

How can i get this code to pull only PIREPS that have been accepted?

Link to comment
Share on other sites

  • 5 months later...
  • Moderators

I think that this should work accordingly:

<?php
$year = date("Y");
$month = date("m")-1;
if($month == 0) { //If it's january, previous month is december.
		    $month = 12;
		    $year -= 1;
}
$pilot = TopPilotData::top_pilot_hours($month, $year, 5);
echo '<table>';
foreach ($pilot as $top) {
		    $pilot = PilotData::GetPilotData($top->pilot_id);
		    echo '<tr>';
		    echo '<td>'.$pilot->firstname.' '.$pilot->lastname.' - '.PilotData::GetPilotCode($pilot->code, $pilot->pilotid).'</td>';
		    echo '<td>'.$top->hours.'</td>';
		    echo '</tr>';
    }
echo '</table>';
?>

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