# Recent 5 Flights

**URL:** <https://forum.phpvms.net/t/recent-5-flights/3038>\
**Category:** Code Snippets\
**Created:** [July 12, 2010, 1:49am UTC](https://forum.phpvms.net/t/recent-5-flights/3038 "2010-07-12T01:49:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff](https://forum.phpvms.net/user_avatar/forum.phpvms.net/jeff/32/78_2.png) [@Jeff](https://forum.phpvms.net/u/Jeff)\
**Post date:** [July 12, 2010, 1:49am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/1 "2010-07-12T01:49:46Z")

</div>

I’m trying to show a table of the 5 recent flights flown, and keep running into a brick wall here. Can someone please post the code to show the last 5 flight.

Flight Number - Departure Airport - Arrival Airport - Flight Time - Pilot - Landing %

---

<div class="post-metadata">

**Author:** ![Jeff](https://forum.phpvms.net/user_avatar/forum.phpvms.net/jeff/32/78_2.png) [@Jeff](https://forum.phpvms.net/u/Jeff)\
**Post date:** [July 12, 2010, 10:34pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/2 "2010-07-12T22:34:19Z")

</div>

Jeff, I’m trying to create a table to place under the map on my home page that shows the last 5 flights flown. kind of like the one on [this page](http://www.flymapleair.com/index.php/) The one that says latest arrivals.

---

<div class="post-metadata">

**Author:** ![Jeff](https://forum.phpvms.net/user_avatar/forum.phpvms.net/jeff/32/78_2.png) [@Jeff](https://forum.phpvms.net/u/Jeff)\
**Post date:** [July 13, 2010, 2:26am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/3 "2010-07-13T02:26:16Z")

</div>

Parse error: syntax error, unexpected T\_ECHO, expecting ‘,’ or ‘;’ in /home/oneworld/public\_html/lib/skins/crystal-II/frontpage\_main.tpl on line 61

> This is line 61
> 
> echo “”;

---

<div class="post-metadata">

**Author:** ![Jeff](https://forum.phpvms.net/user_avatar/forum.phpvms.net/jeff/32/78_2.png) [@Jeff](https://forum.phpvms.net/u/Jeff)\
**Post date:** [July 13, 2010, 2:44am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/4 "2010-07-13T02:44:01Z")

</div>

Parse error: syntax error, unexpected $end in /home/oneworld/public\_html/lib/skins/crystal-II/frontpage\_main.tpl on line 162

> This is line 162

Here is the whole code for that page

```
<div id="mainbox">
<h3>Welcome To One World Virtual</h3>
<?php

// Show the News module, call the function ShowNewsFront
//	This is in the modules/Frontpage folder

MainController::Run('News', 'ShowNewsFront', 5);
?>
<?php
       $flights = PIREPData::getRecentReportsByCount(15);                                                                      
       $string = "";
       foreach($flights as $flight)
       {       
            $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
       }                                                                       
       ?>
       <table>
         <tr>
           <th>LAST 15 FLIGHT LEGS</th>
         </tr>
         <tr>
           <td><p align="center"><img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=690x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br />
             Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>.</p></td>
             </tr>
                   </table>
                   <?php
$count = 5;
$pireps = PIREPData::getRecentReportsByCount($count);
?>

<table>
  <thead>
    <tr>
      <th>Flight #</th>
      <th>Departure</th>
      <th>Arrival</th>
      <th>Duration</th>
      <th>Pilot</th>
      <th>Landing Rate</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>'.$pirep->code.$pirep->flighnum.'</td>";
   echo "<td>'.$pirep->depicao.'</td>";
   echo "<td>'.$pirep->arricao.'</td>";
   echo "<td>'.$pirep->flighttime.'</td>";
   echo "<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>";
   echo "<td>'.$pirep->landingrate.'</td>";
   echo "</tr>";
 }
}
else
{
   echo "<tr><td>There are no recent flights!</td></tr>";
?>
  </tbody>
</table>

</div>

</div>

<div id="sidebar">
 <h3>Pilot Center</h3>

	<?php 
	/* 
	Quick example of how to see if they're logged in or not
	Only show this login form if they're logged in */
	if(Auth::LoggedIn() == false)
	{ ?>
		<form name="loginform" action="<?php echo url('/login'); ?>" method="post">
			<p>Log in to your pilot center or <a href="<?php echo url('/registration'); ?>">register</a><br />
		<input type="text" name="email" value="Email/Pilot ID" onClick="this.value=''" />
			</p>
			<p>
			  <input type="password" name="password" value="Password" />
		  </p>
			<p>
			  <input type="hidden" name="remember" value="on" />
			  <input type="hidden" name="redir" value="index.php/profile" />
			  <input type="hidden" name="action" value="login" />
			  <input type="submit" name="submit" value="Log In" />
		  </p>
 </form>
		<p>
		<?php
	}	
	/* End the Auth::LoggedIn() if */
	else /* else - they're logged in, so show some info about the pilot, and a few links */
	{

	/*	Auth::$userinfo has the information about the user currently logged in
		We will use this next line - this gets their full pilot id, formatted properly */
	$pilotid = PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid);
	?>
	    <strong>Pilot ID: </strong> <?php echo $pilotid ; ?>
	    <strong>Rank: </strong><?php echo Auth::$userinfo->rank;?><br />
	    <strong>Total Flights: </strong><?php echo Auth::$userinfo->totalflights?>, <strong>Total Hours: </strong><?php echo Auth::$userinfo->totalhours;?>
	<br /><?php
	} /* End the else */
	?>

 </p>
		<p>
		  <?php MainController::Run('Mail', 'checkmail'); ?>
		</p>
<h3>Recent Reports</h3>

<?php MainController::Run('PIREPS', 'RecentFrontPage', 5); ?>

<h3>Newest Pilots</h3>

<p>
  <?php MainController::Run('Pilots', 'RecentFrontPage', 5); ?>
 </p>
<h3>Airline Stats</h3>
<p><strong>Total Schedules: </strong><?php echo StatsData::totalschedules(); ?></p>
<p><strong>Total Aircraft: </strong><?php echo StatsData::TotalAircraftInFleet(); ?></p>
<p><strong>Total Pilots: <?php echo StatsData::PilotCount(); ?></strong></p>
<p><strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?></p>
       <p><strong>Total Flights Flown: </strong><?php echo StatsData::TotalFlights(); ?></p>
       <p><strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?></p>
       <p><strong>Passengers Carried: </strong><?php echo StatsData::TotalPaxCarried(); ?></p>
       <p><strong>Fuel Burned (lbs.): </strong><?php echo StatsData::TotalFuelBurned(); ?></p>
       <p><strong>Avg Landing Rate: </strong><?php echo ''.round(TouchdownStatsData::airline_average('airline'), 2); ?></p>
       <p><strong>Total Flights Today: </strong><?php echo StatsData::totalflightstoday(); ?></p>
       <p><strong>Total Cargo Carried: </strong><?php echo StatsData::TotalCargoCarried(); ?>
<h3>Users Online</h3>
<?php
      foreach($usersonline as $pilot)  

       {

               echo "<p>";
               echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />';
               echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' . $pilot->lastname; 
               echo "</p>";

       }

       ?>
              <br />
              Have <?php echo count($usersonline);?> Pilots Online.
              <h3 class="style3">Guests Online </h3>
              <p class="txt-red10"> Have <?php echo count($guestsonline);?> Guests Online.</div>
</div>

```

---

<div class="post-metadata">

**Author:** ![Jeff](https://forum.phpvms.net/user_avatar/forum.phpvms.net/jeff/32/78_2.png) [@Jeff](https://forum.phpvms.net/u/Jeff)\
**Post date:** [July 13, 2010, 3:05am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/5 "2010-07-13T03:05:22Z")

</div>

Yep that works, thanks again Jeff. All I need to do now is skin it…

---

<div class="post-metadata">

**Author:** ![Gabriel\_Fernandez](https://forum.phpvms.net/user_avatar/forum.phpvms.net/gabriel_fernandez/32/51_2.png) [@Gabriel\_Fernandez](https://forum.phpvms.net/u/Gabriel_Fernandez)\
**Post date:** [July 14, 2010, 1:05am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/6 "2010-07-14T01:05:13Z")

</div>

what’s definitive code?

---

<div class="post-metadata">

**Author:** ![Gabriel\_Fernandez](https://forum.phpvms.net/user_avatar/forum.phpvms.net/gabriel_fernandez/32/51_2.png) [@Gabriel\_Fernandez](https://forum.phpvms.net/u/Gabriel_Fernandez)\
**Post date:** [July 14, 2010, 1:54pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/7 "2010-07-14T13:54:53Z")

</div>

thanks, i try use it

---

<div class="post-metadata">

**Author:** ![llju1](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ba9def/32.png) [@llju1](https://forum.phpvms.net/u/llju1)\
**Post date:** [July 15, 2010, 1:10am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/8 "2010-07-15T01:10:01Z")

</div>

I can not get this to show the full flight Number. As we have 5 Wings(Airlines) it only show the letters of the Wings(Airlines) but not the actual flight number. EX. VMC1001 just will show as VMC or 57V0401-1 will only show 57V. any Ideas?

thanks

---

<div class="post-metadata">

**Author:** ![llju1](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/l/ba9def/32.png) [@llju1](https://forum.phpvms.net/u/llju1)\
**Post date:** [July 15, 2010, 6:56pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/9 "2010-07-15T18:56:46Z")

</div>

That did it. Thanks

---

<div class="post-metadata">

**Author:** ![Gabriel\_Fernandez](https://forum.phpvms.net/user_avatar/forum.phpvms.net/gabriel_fernandez/32/51_2.png) [@Gabriel\_Fernandez](https://forum.phpvms.net/u/Gabriel_Fernandez)\
**Post date:** [July 17, 2010, 3:47pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/10 "2010-07-17T15:47:14Z")

</div>

any heave a code skining?

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 26, 2011, 1:29am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/11 "2011-01-26T01:29:02Z")

</div>

Hi guys. I know this post is real old and I hate to necro post, but I must.

I have been itching to add this for a long time but never got around to it. I used the code posted above and it shows up on my site but with some errors.

When it outputs the data to the table it shows up like this :

I have been trying to fix it, but not sure what is going on. Would love some guiding light.

Thanks in advance.

Ray

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 26, 2011, 1:46am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/12 "2011-01-26T01:46:33Z")

</div>

Fixed! I got rid of all the " and replaced with ’ .

Now I want to get rid of the landing rate and add Status. So it would show Pending, Accepted, Rejected etc,etc.

I tried nabbing the code from the viewall\_pireps.tpl but it just tossed me out a syntax error.

Here is the code tossing the error at me. It is the first div line where it says accepted.

Parse error: syntax error, unexpected T\_STRING, expecting ‘,’ or ‘;’ in /home/xxxxxx/public\_html/xxxxxx/lib/skins/brilliancev1/frontpage\_main.tpl on line 87

```
<?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><center>'.$pirep->code.$pirep->flightnum.'</center></td>';
   echo '<td><center>'.$pirep->depicao.'</center></td>';
   echo '<td><center>'.$pirep->arricao.'</center></td>';
   echo '<td><center>'.$pirep->flighttime.'</center></td>';
   echo '<td><center>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</center></td>';
   echo '<td><?php

	if($pirep->accepted == PIREP_ACCEPTED)
		echo '<div id="success">Accepted</div>';
	elseif($pirep->accepted == PIREP_REJECTED)
		echo '<div id="error">Rejected</div>';
	elseif($pirep->accepted == PIREP_PENDING)
		echo '<div id="error">Pending</div>';
	elseif($pirep->accepted == PIREP_INPROGRESS)
		echo '<div id="error">In Flight</div>';

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

```

It is no biggie if I do not get it to work since it is on a dev site only, but would be real nice to get the flight status to work.

And please do ignore all of the center and end center tags. I know they are not right. I just hadn’t got to do it the right way yet.

---

<div class="post-metadata">

**Author:** ![simpilot](https://forum.phpvms.net/user_avatar/forum.phpvms.net/simpilot/32/26_2.png) [@simpilot](https://forum.phpvms.net/u/simpilot)\
**Post date:** [January 26, 2011, 4:53am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/13 "2011-01-26T04:53:35Z")

</div>

You have an extra set of php tags in the file

```
echo '<td><?php

```

and

```
?></td>';

```

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 26, 2011, 4:03pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/14 "2011-01-26T16:03:34Z")

</div>

> You have an extra set of php tags in the file
> 
> echo '\<?php
> 
> and
> 
> ?\>';

I got rid of the extra stuff you suggested and I still get the same exact error.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 26, 2011, 4:04pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/15 "2011-01-26T16:04:30Z")

</div>

> I also changed the original code to single quotes. Not sure why I put the doubles in there. Brain Fart?

Oh stuff like that happens from time to time eh? No biggie. Was a quick easy fix.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 28, 2011, 6:31pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/16 "2011-01-28T18:31:41Z")

</div>

Anyone got a working copy of this they would care to share? Meaning just for flight status. I got all the rest of it working smoothly. I don’t need the touchdown rate so I scrapped it in hopes of getting the flight status in there instead. Like Accepted, pending, Rejected.

---

<div class="post-metadata">

**Author:** ![TAV1702](https://forum.phpvms.net/user_avatar/forum.phpvms.net/tav1702/32/41_2.png) [@TAV1702](https://forum.phpvms.net/u/TAV1702)\
**Post date:** [January 28, 2011, 10:56pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/17 "2011-01-28T22:56:13Z")

</div>

Lorathon, I thank you with everything I have to thank you with! Works great.

---

<div class="post-metadata">

**Author:** ![Chaz](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@Chaz](https://forum.phpvms.net/u/Chaz)\
**Post date:** [February 1, 2011, 9:45am UTC](https://forum.phpvms.net/t/recent-5-flights/3038/18 "2011-02-01T09:45:02Z")

</div>

Just a quick question as I’m not a php wiz…

Is it possible to make the ‘Flight#’ field a link to view the actual pirep? I’ve tried using a **\<a href=** but it keeps throwing up errors as I’m not sure how or where to place it in the data string. Cheers!

---

<div class="post-metadata">

**Author:** ![mark1million](https://forum.phpvms.net/user_avatar/forum.phpvms.net/mark1million/32/15_2.png) [@mark1million](https://forum.phpvms.net/u/mark1million)\
**Post date:** [February 1, 2011, 12:01pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/19 "2011-02-01T12:01:49Z")

</div>

Yes just research how to html out of the script tag, take a look elsewhere on your site, its there in lots of placed

---

<div class="post-metadata">

**Author:** ![Chaz](https://forum.phpvms.net/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@Chaz](https://forum.phpvms.net/u/Chaz)\
**Post date:** [February 1, 2011, 8:56pm UTC](https://forum.phpvms.net/t/recent-5-flights/3038/20 "2011-02-01T20:56:42Z")

</div>

That’s brilliant - thanks!

What was throwing me was the apostrophies ( ’ ) - I just couldn’t seem to get the href in the right place!

Must be nice to be able to know php… Thanks again!

[Next page](https://forum.phpvms.net/t/recent-5-flights/3038.md?page=2)
