Jump to content

Flight Path Map by Airline


Marmus

Recommended Posts

I posted this question in a older skinning thread, but the thread appears to be closed or at least does not show up on the "new posts list and no one may have seen my post.

There is a great code snippet for adding the GC Maps to the site. thread: http://forum.phpvms.net/topic/8040-adding-map/page__hl__+great%20+circle#entry53587

The above thread lists code that will plot the last 10 flights on the main page and ALSO the last 10 flights by a pilot on the pilot's profile page. I would like to modify so that the last 10 flights by a particular airline are shown.

My code snippet question: how to make only the flights from one airline appear?

I assume you can use some form of OperationsData::getAirlineByCode or OperationsData::getAirlineByID....but I have yet to figure out how to use this to make it work. I have to admit, I do not fully understand the "classes" and "public functions" and how they work.

Any help would be much appreciated.

Link to comment
Share on other sites

  • Moderators

The code in the post you mentioned has the following part:

<?php
        $flights = PIREPData::getLastReports($userinfo->pilotid, '10');
        $string = "";
        foreach($flights as $flight)
        {
        $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
        }
        ?>

Now change it to the following:

<?php
        $flights = PIREPData::getLastReports($userinfo->pilotid, '10');
        $string = "";
        foreach($flights as $flight)
        {
           if($flight->code =="ABC")
             {
        $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
        }
}
        ?>

"ABC"is your airline code.

Link to comment
Share on other sites

Thank You, Parviz!

You were quick to answer! And I realized after posting that I may have not asked the question correctly and confused the issue a bit. What you provided is great...it will list last 10 flights within airline "ABC" for the individual pilot on the Pilot profile page. I meant to ask for code snippet to list last 10 flight on "ABC" airline for all pilots as it appears on the Frontpage (not by pilot).

However, I will see if I can fudge the code to work based on what you provided. I gotta learn this sometime, LOL!

Thanks again!

Mark

Link to comment
Share on other sites

OK, That was easy. And I see what you did.

<?php
					 $flights = PIREPData::getRecentReportsByCount(10);																																																																
					 $string = "";
					 foreach($flights as $flight)
					 {
if($flight->code =="FSF")
					 {

					 $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
					 }
}
?>

Next step is to do the same with the table below the map.

Link to comment
Share on other sites

Regarding editing the table listing (see post above):

OK. I tried to edit the table, but not following the code. I am sure it is as easy as the last one, but all these variables get me confused as to what the code is actually doing. Perhaps this portion is not referencing the same variable, so the airline "code" is not available.

I tried inserting an "if" statement like the one you used, but nothing happens. I do not even get an error.

Here is the base code (no revisions):

<!--Start Table-->
<?php
$count = 10;
$pireps = PIREPData::getRecentReportsByCount($count);
?>
<table width="725 px" border="1" bordercolor="#FFFFFF">
<thead>
			 <tr align="center" valign="middle" bgcolor="#7D95AF">
			 <th>Flight #</th>
			 <th>Departure</th>
			 <th>Arrival</th>
			 <th>Duration</th>
			 <th>Pilot</th>
			 <th>Landing Rate</th>
			 <th>Aircraft</th>
			 </tr>
</thead>
	 <tbody>

<?php
if(count($pireps) > 0)
{

foreach ($pireps as $pirep)
{

	 $pilotinfo = PilotData::getPilotData($pirep->pilotid);
	 $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);

	 echo "<tr>";
	 echo "<td align=center> $pirep->code $pirep->flightnum </td>";
	 echo "<td align=center> $pirep->depicao </td>";
	 echo "<td align=center> $pirep->arricao </td>";
	 echo "<td align=center> $pirep->flighttime </td>";
	 echo "<td align=center> $pilotid $pilotinfo->firstname $pilotinfo->lastname </td>";
	 echo "<td align=center> $pirep->landingrate </td>";
	 echo "<td align=center> $pirep->aircraft </td>";
	 echo "</tr>";

}
}
else
{
	 echo "<tr><td>There are no recent flights!</td></tr>";
}
?>
</table>
</td>

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