Jump to content

Live flight board now showing same pilot each flight.


ahughes3

Recommended Posts

Hi all, hoping someone can help me shed light on an issue that has arisen on my VA site.

I have a flight boards page showing, Live Flights, Recent Flights and Booked Flights. All has been working fine until a few days ago I noticed that the Live Flights showed three flights all being done by the same person. When we look on the Live Map, we can see that this is in fact three different pilots.

The strange thing is, nothing has been changed on the website, pages or anything, it just started happening. So I thought I'd post my code for the live table and see if anyone else has had either a similar problem, can see a problem with the code or can suggest steps to try and resolve it.

Thanks in advance.

<!-- Start of live flights table -->
				    <div class="col-md-12 page-content">
				    <h2>Live Flights</h2>
				    <div class="stats-table">
				    <table>
					    <tr>
						    <th>Pilot</th>
						    <th>Flight</th>
						    <th>Departure</th>
						    <th>Arrival</th>
						    <th>Aircraft</th>
						    <th>Status</th>
						    </tr>
						    <?php
						    $results = ACARSData::GetACARSData();
						    if (count($results) > 0)
						    {
						    foreach($results as $flight)
						    {	 
						    ?>
					    <tr>
					    <?php
					    $count = 10;
					    $pireps = PIREPData::getRecentReportsByCount($count);
					    ?>
										 <?php if($flight->phasedetail == "Boarding") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "Arrived") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "On Approach") { echo "<img style='padding-left:3px;' src=''>"; }
	    ?>




										 <?php
						    foreach ($pireps as $pirep)
						    {
									 $pilotinfo = PilotData::getPilotData($pirep->pilotid);
									 $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
    }
										 ?>
								   <td><?php echo'<a href="'.SITE_URL.'/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</a>';?></td>

										 <td><?php echo $flight->flightnum;?></td>
										 <td><?php echo $flight->depname;?></td>
										 <td><?php echo $flight->arrname;?></td>
										 <td><?php echo $flight->aircraftname;?></td>
										 <td><?php if($flight->phasedetail
							   != 'Paused') { echo $flight->phasedetail; }
						    else { echo "Cruise"; }?></font></td>
								 </tr>
						    <?php		  
												 }
										 } else { ?>
												 <tr><td width="20%" align="center" colspan="6" style="padding: 5px; font-size: 13px; font-weight: bold; color: #3399FF;">No Flights in Progress!</td></tr>
										 <?php
										 }
										 ?>
					    </table>
				    </div>
				    </div>

Link to comment
Share on other sites

  • Members

Can you try this ?

<?php
   <div class="col-md-12 page-content">
   <h2>Live Flights</h2>
   <div class="stats-table">
   <table>
   <tr>
   <th>Pilot</th>
   <th>Flight</th>
   <th>Departure</th>
   <th>Arrival</th>
   <th>Aircraft</th>
   <th>Status</th>
   </tr>
   <?php
   $results = ACARSData::GetACARSData();
   if (count($results) > 0)
   {
    foreach($results as $flight)
    {	   
    ?>
    <tr>
	    <?php
		    $count = 10;
		    $pireps = PIREPData::getRecentReportsByCount($count);
	    ?>
	    <?php if($flight->phasedetail == "Boarding") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "Arrived") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "On Approach") { echo "<img style='padding-left:3px;' src=''>"; }
	    ?>


	    <?php
		    foreach ($pireps as $pirep)
		    {
			    $pilotinfo = PilotData::getPilotData($pirep->pilotid);
			    $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid);
		    }
	    ?>
	    <td><?php echo'<a href="'.SITE_URL.'/index.php/profile/view/'.$flight->pilotid.'">'.$flight->pilotname.' '.$flight->lastname.'</a>';?></td>
	    <td><?php echo $flight->flightnum;?></td>
	    <td><?php echo $flight->depname;?></td>
	    <td><?php echo $flight->arrname;?></td>
	    <td><?php echo $flight->aircraftname;?></td>
	    <td><?php if($flight->phasedetail
				    != 'Paused') { echo $flight->phasedetail; }
			    else { echo "Cruise"; }?></font></td>
    </tr>
    <?php			
    }
   } else { ?>
   <tr><td width="20%" align="center" colspan="6" style="padding: 5px; font-size: 13px; font-weight: bold; color: #3399FF;">No Flights in Progress!</td></tr>
   <?php
   }
?>
												    </table>
										    </div>
										    </div>
?>

Link to comment
Share on other sites

Thanks Vangelis, but your changes throw up an error on line 2. Not sure what the error is because it looks ok to me. Also, the table coding is one of three tables that go on the page but I didn't paste the other tables as they are working just fine. Although, could something in those tables be affecting the first table?

What's really odd is that the whole thing was working great for a while and then just randomly stopped working. Anyways, posted the whole page code below to see if that helps.

Thanks again for your help. :)

<!-- Start of live flights table -->
<div class="col-md-12 page-content">
 <h2>Live Flights</h2>
 <div class="stats-table">
   <table>
  <tr>
    <th>Pilot</th>
    <th>Flight</th>
    <th>Departure</th>
    <th>Arrival</th>
    <th>Aircraft</th>
    <th>Status</th>
  </tr>
  <?php $results=A CARSData::GetACARSData(); if (count($results)> 0) { foreach($results as $flight) { ?>
  <tr>
    <?php $count=1 0; $pireps=P IREPData::getRecentReportsByCount($count); ?>
    <?php if($flight->phasedetail == "Boarding") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "Arrived") { echo "<img style='padding-left:3px;' src=''>"; } elseif($flight->phasedetail == "On Approach") { echo "<img style='padding-left:3px;'
    src=''>"; } ?>

    <?php foreach ($pireps as $pirep) { $pilotinfo=P ilotData::getPilotData($pirep->pilotid); $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); } ?>
    <td>
	  <?php echo '<a href="'.SITE_URL. '/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</a>';?></td>
    <td>
	  <?php echo $flight->flightnum;?></td>
    <td>
	  <?php echo $flight->depname;?></td>
    <td>
	  <?php echo $flight->arrname;?></td>
    <td>
	  <?php echo $flight->aircraftname;?></td>
    <td>
	  <?php if($flight->phasedetail != 'Paused') { echo $flight->phasedetail; } else { echo "Cruise"; }?></font>
    </td>
  </tr>
  <?php } } else { ?>
  <tr>
    <td width="20%" align="center" colspan="6" style="padding: 5px; font-size: 13px; font-weight: bold; color: #3399FF;">No Flights in Progress!</td>
  </tr>
  <?php } ?>
   </table>
 </div>
</div>
<!-- Start of recent flights table -->
<div class="col-md-12 page-content">
 <h2>Recent Flights</h2>
 <div class="stats-table">
   <table>
  <tr>
    <th>Flight</th>
    <th>Pilot</th>
    <th>Departure</th>
    <th>Arrival</th>
    <th>Aircraft</th>
    <th>Duration</th>
    <th>V/S</th>
    <th>Info</th>
  </tr>
  <?php $count=1 0; $pireps=P IREPData::getRecentReportsByCount($count); ?>
  <?php if (count($results)> 0); if (count($pireps) > 0) { foreach ($results as $flight); foreach ($pireps as $pirep) { $pilotinfo = PilotData::getPilotData($pirep->pilotid); $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); $acrid = OperationsData::getAircraftByReg($pirep->registration);
  $results = ACARSData::GetACARSData(); $fcode = substr($flight->flightnum, 0, 3); echo '
  <tr>'; echo '
    <td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>'; echo '
    <td><a href="'.SITE_URL.'/index.php/profile/view/'.$pilotinfo->pilotid.'">'.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</a></td>'; echo '
    <td>'.$pirep->depicao.'</td>'; echo '
    <td>'.$pirep->arricao.'</td>'; echo '
    <td>'.$pirep->aircraft.'</td>'; echo '
    <td>'.$pirep->flighttime.'</td>'; echo '
    <td>'.$pirep->landingrate.' ft/m</td>'; if($pirep->accepted == PIREP_ACCEPTED) echo '
    <td><span class="label label-important"><font color="green">Accepted</font></span></td>'; elseif($pirep->accepted == PIREP_REJECTED) echo '
    <td><span class="label label-important"><font color="red">Rejected</font></span></td>'; elseif($pirep->accepted == PIREP_PENDING) echo '
    <td><span class="label label-warning"><font color="orange">Pending</font></span></td>'; elseif($pirep->accepted == PIREP_INPROGRESS) echo '
    <td>On Progress</td>'; echo '</tr>'; } } else { echo '
  <tr>
    <td>There are no recent Flights!</td>
  </tr>'; } ?>
   </table>
 </div>
 <!-- End of recent flights table -->
</div>
<!-- Start of booked flights table -->
<div class="col-md-12 page-content">
 <h2>Booked Flights</h2>
 <div class="stats-table">
   <?php MainController::Run( 'FrontBids', 'RecentFrontPage', 10); ?>
 </div>
</div>

Link to comment
Share on other sites

Update: - I have noticed that when there is only one person with a live flight, the "live flight" board shows the correct info. However, as soon as there are two or more pilots flying that's when the problem occurs. The pilot named on the live flights is not even necessarily a pilot who is actually flying either. I can't see anything wrong with the code and nothing has changed on my server so I'm still stumped.

Anyone have any ideas at all?

Link to comment
Share on other sites

Thanks as always Vangelis for the offer of support. My flightboards page is there in it's entirety. I'm not worried about others using it as I got it from snippets that I tweaked.

It is definitely doing something in relation to the number of live flights. When it's one it works fine, as soon as there are two or more it chooses a pilot (maybe at random) and sets all live flights to that pilot.

So there are three tables on that code, Live Flights, then Recent Flights and then Booked Flights.

:)

Link to comment
Share on other sites

Could the issue be something to do with the fact that two different flight tables are asking for the same information at the same time through the page? If so, would someone be able to help me identify how to alter the code so that rather than the "database call" running twice, it runs once and then the coding for both of the flight tables that use the information just processes it in their cells. Does anyone think that would alleviate the problem?

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