Hi guys,
Happy New Year!
I have a question, I've been trying to add the flightboard and it is working partially. I have adjusted the code which can be found elsewhere in this topic to reflect our circumstances etc. but the flight board comes up with a few gaps.
First, the code I used/altered
<?php
$h = "6";// Hour for time zone goes here e.g. +7 or -4, just remove the + or -
$hm = $h * 60;
$ms = $hm * 60;
$gmdate = gmdate("H:i", time()+($ms));
#
#
$query = "SELECT * FROM phpvms_schedules WHERE deptime>='$gmdate' AND depicao='UAAA' ORDER BY deptime";
#
$list = DB::get_results($query);
#
echo '<h1>Almaty Departures - Current time is '.$gmdate.'</h1>';
#
echo '<table width="100%" border="1" bgcolor="#FFFFFF" >';
#
echo '<tr><td><b>Flight Number</b></td><td><b>Arrival</b></td><td><b>Departure Time</b></td><td><b>Aircraft</b></td><td><b>Status</b></td></tr>';
#
$count = 0;
#
foreach($list as $flight) {
#
if(date('G:i') >= '23') {
#
$time = '0';
#
}
#
else {
#
$time = date('G:i');
#
}
#
if(($flight->deptime + 0) >= $time) {
#
if($count < 5) {
#
$aircraft = OperationsData::getAircraftInfo($flight->aircraft);
$depname = OperationsData::RetrieveAirportInfo($flight->depicao);
$arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
echo '<tr><td>TZE'.$flight->flightnum.'</td><td>'.$arrname->name.'</td><td>'.$flight->deptime.'</td><td>'.$aircraft->fullname.'</td>';
#
echo '<td>';
#
$minutes = explode(':', $flight->deptime);
#
if($minutes['0'] <= date('G')) {
#
if(($minutes['1'] - date('i')) <= 0) {
#
echo 'Departed';
#
}
#
elseif(($minutes['1'] - date('i')) <= 15 && ($minutes['1'] - date('i')) >= 1) {
#
echo 'Final Call';
#
}
#
elseif(($minutes['1'] - date('i')) >= 30 && ($minutes['1'] - date('i')) <= 20) {
#
echo 'Proceed to Gate';
#
}
#
else {
#
echo 'Scheduled Departure';
#
}
#
}
#
else {
#
echo 'Scheduled Departure';
#
}
#
echo '</td></tr>';
#
$count++;
#
}
#
}
#
}
#
echo '</table>';
#
#
echo '<h1>Expected Arrivals - Current Time is '.date('G:i').'</h1>';
#
echo '<table width="90%" border="1" bgcolor="#FFFFFF" >';
#
echo '<tr><td><b>Flight Number</b></td><td><b>Departure</b></td><td><b>Arrival</b></td><td><b>Arrival Time</b></td><td><b>Aircraft</b></td><td><b>Status</b></td></tr>';
#
$count = 0;
#
foreach($list as $flight) {
#
if(date('G:i') >= '23') {
#
$time = '0';
#
}
#
else {
#
$time = date('G:i');
#
}
#
if(($flight->arrtime + 0) >= $time) {
#
if($count < 5) {
#
$aircraft = OperationsData::getAircraftInfo($flight->aircraft);
$depname = OperationsData::RetrieveAirportInfo($flight->depicao);
$arrname = OperationsData::RetrieveAirportInfo($flight->arricao);
#
echo '<tr><td>TZE'.$flight->flightnum.'</td><td>'.$depname->name.'</td><td>'.$arrname->name.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>';
#
echo '<td>';
#
$minutes2 = explode(':', $flight->arrtime);
#
if($minutes2['0'] <= date('G')) {
#
if($minutes2['1'] - (date('i')) >= 30) {
#
echo 'On Time';
#
}
#
elseif(($minutes2['1'] - date('i')) >= 1 && ($minutes2['1'] - date('i')) <= 30) {
#
echo 'On Approach';
#
}
#
else {
#
echo 'Landed';
#
}
#
#
}
#
else {
#
echo 'On Time';
#
}
#
echo '</td></tr>';
#
$count++;
#
}
#
}
#
}
#
echo '</table>';
$flights = PIREPData::getRecentReportsByCount(10);
$string = "";
foreach($flights as $flight)
{
$string = $string.$flight->depicao.'+-+'.$flight->arricao.',+';
}
?>
Here's a screenshot of what I mean -
Note the gap in the destination on the second or so line. Don't know how that happens? Maybe this has something to do with flights that don't happen each day?
Also, the code suggests the status should receive updates from Scheduled Departure to Go To Gate etc. and that's not happening either.
As I know pretty much not a great deal about PHP, could anyone please suggest any solutions?
Many thanks
Peter