Jump to content

Recommended Posts

Posted

<p>Hi.<br />

I want to know how to display top pilots hour in the front page.<br />

i ued this code

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

but it displays nothing. please help.</p>

  • Moderators
Posted

You will have to state the $month and the $year variables before. In your case the following should work i think:

<?php
$month = date("m");
$year = date("Y");
echo TopPilotData::top_pilot_hours($month, $year, 5) ;

Posted

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.

Posted

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

  • Moderators
Posted

You are a php pro, as you stated above, why can't you understand what Manuel said? It is an array and you have to create a new table and just use foreach to show the data.

Ι hate it when someone expect everything on his plate...

  • Like 1
  • Administrators
Posted

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

Posted

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

  • Administrators
Posted

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?

  • Administrators
Posted

This code

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

is not pulling any records

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.

Posted

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

Posted

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
  • 4 weeks later...
Posted

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 {
}
?>

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

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?

Posted

Also, on the regular table, on the All time table it only shows approved flights, but the monthly stats shows all PIREPs including rejected PIREPS. how can i get that to only show approved PIREPs?

Posted

Also, is there a reason why the All time stats are showing pilots about an hour more than the monthly stats? (This our first month of operation) they should all be the same numbers.

  • 5 months later...
Posted

Hi Dave,

I am wanting to pull top 5 pilots for the previous month for hours flown, to show on home page. how would I get it, i have tried a few of the codes but it doesnt seem to show and I gt errors

  • Moderators
Posted

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>';
?>

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