CrashGordon Posted May 5, 2010 Report Posted May 5, 2010 Is it possible to have a flight board that first checks the system time and then displays the following. Flight Number - Departure ICAO - Arrival - Aircraft - Status This would be eye candy, rather than actual status, since most of us have more flights than pilots. The board would display only flights with an arrival time within 2 hours of system time. Flight status would, depending onwhere they are in relation to system time, be on time, arriving, arrived. I suppose something similar could be done for departures, but I'm trying to keep it as simple as possible. Does this sound like something that could be done? Or, maybe I should ask if it has already been done. 3 Quote
joshua.john Posted May 6, 2010 Report Posted May 6, 2010 Is it possible to have a flight board that first checks the system time and then displays the following. Flight Number - Departure ICAO - Arrival - Aircraft - Status This would be eye candy, rather than actual status, since most of us have more flights than pilots. The board would display only flights with an arrival time within 2 hours of system time. Flight status would, depending onwhere they are in relation to system time, be on time, arriving, arrived. I suppose something similar could be done for departures, but I'm trying to keep it as simple as possible. Does this sound like something that could be done? Or, maybe I should ask if it has already been done. Sounds like a good idea! hopefully it can be done Quote
CrashGordon Posted May 6, 2010 Author Report Posted May 6, 2010 Don't laugh, but I am trying to do it. Looking at code from other pages, trying to figure out what variable names I need, with one eye on the monitor and the other on a book on PHP. The results, so far are either infuriating or hysterically funny. I don't know which is worse. My approach is this: Get the system time and convert it to the 24 hour format I'm using in the routes. Get the routes with arrival times that are equal to or plus/minus one hour to the system time. Display those routes in a table with flight number, departure and arrival ICAOs, a/c tail number and verbiage based on how far from the system time the arrival time is. Quote
MrAmsterdam Posted May 6, 2010 Report Posted May 6, 2010 Sounds cool!! Hope you will be succesful ! Regards, Lucas Quote
joshua.john Posted May 6, 2010 Report Posted May 6, 2010 Don't laugh, but I am trying to do it. Looking at code from other pages, trying to figure out what variable names I need, with one eye on the monitor and the other on a book on PHP. The results, so far are either infuriating or hysterically funny. I don't know which is worse. My approach is this: Get the system time and convert it to the 24 hour format I'm using in the routes. Get the routes with arrival times that are equal to or plus/minus one hour to the system time. Display those routes in a table with flight number, departure and arrival ICAOs, a/c tail number and verbiage based on how far from the system time the arrival time is. Is this what you want to do? http://xlvirtualairways.simmiles.com/arrivals.php Quote
CrashGordon Posted May 6, 2010 Author Report Posted May 6, 2010 Similar, but instead of the last two columns, a column with verbiage such as on time, arriving, landed, arrived (based on schedule time vs. system time). That way, any time the page was loaded, different flights would be displayed. A departure board could be done similarly, with different status verbiage. Quote
joshua.john Posted May 6, 2010 Report Posted May 6, 2010 Similar, but instead of the last two columns, a column with verbiage such as on time, arriving, landed, arrived (based on schedule time vs. system time). That way, any time the page was loaded, different flights would be displayed. A departure board could be done similarly, with different status verbiage. Well im defo interested. Something like that would be good Quote
Tom Posted May 7, 2010 Report Posted May 7, 2010 If you don't mind I might have a go at this one also, I've been thinking about it for a while and have a good idea to make it realistic looking. Quote
CrashGordon Posted May 7, 2010 Author Report Posted May 7, 2010 I certainly don't mind, Tom, but you might want to look at this, before reinventing the wheel. http://forum.phpvms....live-timetable/ EDIT: That software won't serve my needs. Back to trying to write code. Quote
Administrators simpilot Posted May 8, 2010 Administrators Report Posted May 8, 2010 This is a pretty dirty way to do it (the sql query's really need to be in a data class, not in the page) but you could build a module around it <?php $query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC"; $list = DB::get_results($query); echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; echo '<table width="100%" border="1">'; echo '<tr><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</td></tr>'; $count = 0; foreach($list as $flight) { if(($flight->arrtime + 0) > date('G:i')) { if($count < 5) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; echo '<td>'; if(($flight->arrtime - date('G:i')) <= 1) { echo 'Arriving Soon'; } else { echo 'In Flight'; } echo '</td></tr>'; $count++; } } } echo '</table>'; ?> This will show the next 5 flights scheduled to arrive and is written to work with 24 hour date format, so if you are using 12 hour date format with am/pm in your schedules you will have to modify the date function. It should look something like Pretty plain but you can build it up how you would like and skin it. Quote
CrashGordon Posted May 8, 2010 Author Report Posted May 8, 2010 Wow! That is what I'm looking for. Will give it a try and see if I can get it to work here. Thanks. Quote
CrashGordon Posted May 8, 2010 Author Report Posted May 8, 2010 I wish I could report I've got it working, but if that happened, whatever would I do for the rest of the day. Quote
Administrators simpilot Posted May 9, 2010 Administrators Report Posted May 9, 2010 I wish I could report I've got it working, but if that happened, whatever would I do for the rest of the day. Is there any output at all? Do you have any schedules or aircraft? It works for me here on ver 934. If there is any error please post it. Quote
CrashGordon Posted May 9, 2010 Author Report Posted May 9, 2010 I've obviously missed something I need to do, because it is only echoing the variables and some of the code. I don't know my you know what from my elbow, when it comes to php. This is the output I get. I obviously have failed to do something necessary. I have about 30 aircraft and 700 routes. I've spent all day adding routes, so at this point I can't see straight. I'll look at this again in the morning to see if I can figure what I screwed up. Quote
Moderators mark1million Posted May 9, 2010 Moderators Report Posted May 9, 2010 Hi, It looks looke you are adding this via the add page in the admin section, just add the code in to the frontpage_main,tpl, when i tried earlier nothing was displayed in the table ill have another look at it again because like the post says its great eye candy Quote
Moderators mark1million Posted May 9, 2010 Moderators Report Posted May 9, 2010 How strange is that, i have just done it again and its populated, it could be something to do with the time though, last night it was23:45 when i tried today its 11:04, ill let you know when it get to 13:00 if it still works. Quote
Administrators simpilot Posted May 9, 2010 Administrators Report Posted May 9, 2010 I've obviously missed something I need to do, because it is only echoing the variables and some of the code. I don't know my you know what from my elbow, when it comes to php. This is the output I get. I obviously have failed to do something necessary. I have about 30 aircraft and 700 routes. I've spent all day adding routes, so at this point I can't see straight. I'll look at this again in the morning to see if I can figure what I screwed up. Remember that this is php coding - it needs to be enclosed in php tags - ie <?php and ?> I have changed the original post to include them - sorry. Quote
Administrators simpilot Posted May 9, 2010 Administrators Report Posted May 9, 2010 How strange is that, i have just done it again and its populated, it could be something to do with the time though, last night it was23:45 when i tried today its 11:04, ill let you know when it get to 13:00 if it still works. If this is what you guys are looking for I will have to mess with it a little. Right now it is just looking for upcoming flights between the current time and midnight, it does not look "around the corner" until after midnight. Quote
CrashGordon Posted May 9, 2010 Author Report Posted May 9, 2010 Remember that this is php coding - it needs to be enclosed in php tags - ie <?php and ?> I have changed the original post to include them - sorry. I'm as dumb as I look. I forgot to add the tags. Now, it works. Quote
CrashGordon Posted May 9, 2010 Author Report Posted May 9, 2010 Now, that I've got it working, I added the flight number. If it helps others as clueless about PHP as I am, the code is here. <?php $query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC"; $list = DB::get_results($query); echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; echo '<table width="100%" border="1">'; echo '<tr><td>Flight Number</td><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</td></tr>'; $count = 0; foreach($list as $flight) { if(($flight->arrtime + 0) > date('G:i')) { if($count < 5) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; echo '<td>'; if(($flight->arrtime - date('G:i')) <= 1) { echo 'Arriving Soon'; } else { echo 'In Flight'; } echo '</td></tr>'; $count++; } } } echo '</table>'; ?> Now that you showed me how this type of thing is done, I'm doing a departure board. Quote
CrashGordon Posted May 9, 2010 Author Report Posted May 9, 2010 I have this in frontpage_mail.tpl, now. I have to look at the schedule to see if it is working as expected. I also have to explore having one table sort based on departure dime and the other on arrival time. When it is working properly, I'll post the code. EDIT: I changed the code to get the departures working, though I still need to add another parameter to show recently departed flights. Quote
CrashGordon Posted May 10, 2010 Author Report Posted May 10, 2010 I pretty much expected this to happen when it got to this time of nite. There is nothing to specify that the hour after 23 isn't 24, but 0. I'm not sure I can cobble together the "correct" fix, but having the board down for 1 hour out of 24 is something I can live with. I suppose I could put some code in that if the"hour" is 23, it gets changed to 0. That would give me the same display for 2 hours, but there would be some flights listed. Just thinking out loud here. It would probably mean that I couldn't display the current time twice, but that's no problem. Some pseudo code here: get current time display current time if current time = 23 set current time to minus 1 else proceed as normal Would setting the current time to minus 1, then cause it to display flights beginning in the current time+1 (meaning 00:00 and after)? That would at least overcome the problem of no flights appearing. Please don't laugh too loudly. Quote
Administrators simpilot Posted May 10, 2010 Administrators Report Posted May 10, 2010 Give this a shot, works for me to get the flights after the midnight hour. <?php $query = "SELECT * FROM phpvms_schedules ORDER BY arrtime + 0 ASC"; $list = DB::get_results($query); echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; echo '<table width="100%" border="1">'; echo '<tr><td>Flight Number</td><td>Departure</td><td>Arrival</td><td>Arrival Time</td><td>Aircraft</td><td>Status</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); echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; echo '<td>'; if(($flight->arrtime - $time) <= 1) { echo 'Arriving Soon'; } else { echo 'In Flight'; } echo '</td></tr>'; $count++; } } } echo '</table>'; ?> Quote
CrashGordon Posted May 10, 2010 Author Report Posted May 10, 2010 I'll try it later today. Does it show flights from 00:00 or from 01:00? Quote
MrAmsterdam Posted May 10, 2010 Report Posted May 10, 2010 Hey guys, thanks for this solution!! Is there any possibility that you post the php code for the departures as well? :-) By the way, the time on my side is fine it's a 24h format. but the only problem is that my location the time is +6 hours... or is this zulu time? Thanks again guys! Lucas ps. the data showing is not correct at the moment. should i wait a day? www.serious-airlines.com Quote
CrashGordon Posted May 10, 2010 Author Report Posted May 10, 2010 This is what is running on my site, right now. Omega-Air Virtual Airlines I reduced the width to 80% from 100% to fit my site better. I also reduced the table border from 1 to 0. I also changed the verbiage a little to suit my own taste. $query = "SELECT * FROM phpvms_schedules ORDER BY deptime + 0 ASC"; $list = DB::get_results($query); echo '<h3>Upcoming Departures - Current Time is '.date('G:i').'</h3>'; echo '<table width="80%" border="0">'; echo '<tr><td><b>Flight Number</b></td><td><b>Departure</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 < 10) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->deptime.'</td><td>'.$aircraft->fullname.'</td>'; echo '<td>'; if(($flight->deptime - date('G:i')) <= 1) { echo 'Now Boarding'; } else { echo 'Scheduled Departure'; } echo '</td></tr>'; $count++; } } } echo '</table>'; echo '<h3>Upcoming Arrivals - Current Time is '.date('G:i').'</h3>'; echo '<table width="80%" border="0">'; 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 < 10) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><td>'.$flight->flightnum.'</td><td>'.$flight->depicao.'</td><td>'.$flight->arricao.'</td><td>'.$flight->arrtime.'</td><td>'.$aircraft->fullname.'</td>'; echo '<td>'; if(($flight->arrtime - date('G:i')) <= 1) { echo 'Arriving Soon'; } else { echo 'On Time'; } echo '</td></tr>'; $count++; } } } echo '</table>'; I have it running in frontpage_main_tpl. If you want it as a stand-alone page, remember to it in in <?php and ?> It isn't perfect, yet, but it does work. Not being proficient in PHP, I still have to figure out how to make it pretty. Oops, almost forgot to mention this, but as it stands now, it is possible for the arrival board to show a flight as in flight or on time while it is still boarding in the departure board. Quote
CrashGordon Posted May 10, 2010 Author Report Posted May 10, 2010 I forgot to mention earlier, that I had kludged both the departure and arrival code into one blob. For that reason the sort is done on the departure ICAO, only. I'm working on displaying more statuses, such as on approach, final call, etc. I'm also trying to display these based on the number of minutes before and after the current time, rather than the hour. Thanks to simpilot, the hard part is done. I'm just tinkering with bits and pieces. Quote
CrashGordon Posted May 11, 2010 Author Report Posted May 11, 2010 I waited for this hour because I figured when the server time hit 23 and the new code changed it to 0, the results would be interesting. First, there are flights in the schedule with departure or arrival times of 00:15 or similar. They don't appear because the forst hour after 0 is 01:00. And for some reason nothing displays as arriving soon or now boarding when some of them should show scheduled departure on time (in flight) instead of arriving soon. Still, there is only one hour in 24 that has this problem. Here is what appears after the time goes to the next day. Quote
MrAmsterdam Posted May 12, 2010 Report Posted May 12, 2010 Hey guys, is it possible to set the time + 6 hours ? The time is set to us time and i need the dutch time... :-) Can i adjust anything in the php code? Regards, Lucas Quote
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.