Tameem Posted September 6, 2014 Report Share Posted September 6, 2014 <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> Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted September 6, 2014 Moderators Report Share Posted September 6, 2014 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) ; Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 6, 2014 Author Report Share Posted September 6, 2014 Sorry but that didn't work also Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted September 6, 2014 Moderators Report Share Posted September 6, 2014 Where did you place it? Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 8, 2014 Author Report Share Posted September 8, 2014 At the frontpage Quote Link to comment Share on other sites More sharing options...
Members Vangelis Posted September 9, 2014 Members Report Share Posted September 9, 2014 Close the php tag at the end try to add ?> Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 10, 2014 Author Report Share Posted September 10, 2014 Yes i know actually I'm a php pro but the problem is the code is not showing any thing unless it is not working Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 12, 2014 Author Report Share Posted September 12, 2014 Please help Quote Link to comment Share on other sites More sharing options...
mseiwald Posted September 12, 2014 Report Share Posted September 12, 2014 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. Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 13, 2014 Author Report Share Posted September 13, 2014 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 Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 15, 2014 Author Report Share Posted September 15, 2014 Help please!! Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted September 15, 2014 Moderators Report Share Posted September 15, 2014 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... 1 Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted September 16, 2014 Administrators Report Share Posted September 16, 2014 <?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 Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 18, 2014 Author Report Share Posted September 18, 2014 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 Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 21, 2014 Author Report Share Posted September 21, 2014 Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 22, 2014 Author Report Share Posted September 22, 2014 plz help Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 22, 2014 Author Report Share Posted September 22, 2014 This code <?php echo TopPilotData::top_pilot_hours($month, $year, 5) ; ?> is not pulling any records Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted September 23, 2014 Administrators Report Share Posted September 23, 2014 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? Quote Link to comment Share on other sites More sharing options...
Administrators simpilot Posted September 23, 2014 Administrators Report Share Posted September 23, 2014 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. Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 23, 2014 Author Report Share Posted September 23, 2014 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 Quote Link to comment Share on other sites More sharing options...
Tameem Posted September 23, 2014 Author Report Share Posted September 23, 2014 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>'; } ?> 1 Quote Link to comment Share on other sites More sharing options...
Ariel Posted October 18, 2014 Report Share Posted October 18, 2014 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 { } ?> Quote Link to comment Share on other sites More sharing options...
Tameem Posted October 27, 2014 Author Report Share Posted October 27, 2014 Yes thanks alot Vanity Quote Link to comment Share on other sites More sharing options...
Taran Posted January 31, 2015 Report Share Posted January 31, 2015 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? Quote Link to comment Share on other sites More sharing options...
Taran Posted January 31, 2015 Report Share Posted January 31, 2015 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? Quote Link to comment Share on other sites More sharing options...
Taran Posted January 31, 2015 Report Share Posted January 31, 2015 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. Quote Link to comment Share on other sites More sharing options...
shaun105 Posted July 30, 2015 Report Share Posted July 30, 2015 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 Quote Link to comment Share on other sites More sharing options...
Moderators servetas Posted July 30, 2015 Moderators Report Share Posted July 30, 2015 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>'; ?> Quote Link to comment Share on other sites More sharing options...
shaun105 Posted July 31, 2015 Report Share Posted July 31, 2015 Great just what i was looking for and its done the trick . Many thanks for your great support Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.