HighFlyerPL185 Posted January 26, 2013 Report Posted January 26, 2013 Hi there, I am considering creating a Departure board, however I was wondering how can I extract a selected number of upcoming departures? For example, next 10 or 15 departures. Quote
Sava Posted January 26, 2013 Report Posted January 26, 2013 Where would it be pulling data from? The schedules times or the bids placed. If its the schedules, then you check first for all schedules from today's day, then you find the ones with the closest time and limit it to first X schedules. Quote
HighFlyerPL185 Posted January 26, 2013 Author Report Posted January 26, 2013 Thanks for your reply Sava, I did mean schedules indeed. How would I find the closest ones to the current time, but only so it finds after the current time? It would be useless to have schedules that have already departed, I guess Quote
mischka Posted January 27, 2013 Report Posted January 27, 2013 here's the query I use: $utc_now_str = gmdate("H:i"); $query= "SELECT ".TABLE_PREFIX."schedules.id, deptime, arrtime, code, flightnum, arricao, ".TABLE_PREFIX."airports.name destination, depicao, aircraft, ".TABLE_PREFIX."aircraft.icao equipment, bidid, round( time_to_sec( timediff( time( str_to_date( deptime, '%H:%i' ) ) ,'".$utc_now_str."' ) ) /60, 0 ) timediff FROM ".TABLE_PREFIX."schedules, ".TABLE_PREFIX."aircraft, ".TABLE_PREFIX."airports WHERE code = 'EUR' AND locate(dayofweek(convert_tz(now(),'+1:00','+0:00'))-1,".TABLE_PREFIX."schedules.daysofweek)>0 AND ".TABLE_PREFIX."schedules.arricao = ".TABLE_PREFIX."airports.icao AND ".TABLE_PREFIX."schedules.aircraft = ".TABLE_PREFIX."aircraft.id AND round( time_to_sec( timediff( time( str_to_date( deptime, '%H:%i' ) ) , '".$utc_now_str."' ) ) /60, 0 ) <60 AND round( time_to_sec( timediff( time( str_to_date( deptime, '%H:%i' ) ) , '".$utc_now_str."' ) ) /60, 0 ) > -15 ORDER BY timediff limit 12"; The timetable is on the frontpage of my VA. Quote
HighFlyerPL185 Posted January 27, 2013 Author Report Posted January 27, 2013 That's a nice board mischka Thanks for your reply However, I am struggling to put your query into a table, how can I achieve this? I'm slightly bedazzled by this, and I was wondering whether foreach would be the way to do this? I have changed the table prefix into phpVMS_ Quote
mischka Posted January 28, 2013 Report Posted January 28, 2013 Hey highflyer, yes, you would use foreach, just like you would on any other "recordset". I posted the query assuming you'd know how to implement it in the code the table_prefix variable should be already set in the config.php so you didn't have to change it. 2 Quote
sherming Posted January 28, 2013 Report Posted January 28, 2013 That's a really nice departure board mischka Quote
HighFlyerPL185 Posted January 28, 2013 Author Report Posted January 28, 2013 Hey highflyer, yes, you would use foreach, just like you would on any other "recordset". I posted the query assuming you'd know how to implement it in the code the table_prefix variable should be already set in the config.php so you didn't have to change it. Sorry for being a pain in the backside, but I am having trouble implementing the query in. I've wrote a foreach statement, but it's probably wrong and embarrasing, hence it's showing a Warning: Invalid argument supplied for foreach(). Do you have any example of how I'd implement it or maybe which variables I should use for the foreach statement? Quote
Moderators Parkho Posted January 28, 2013 Moderators Report Posted January 28, 2013 Hey highflyer, yes, you would use foreach, just like you would on any other "recordset". I posted the query assuming you'd know how to implement it in the code the table_prefix variable should be already set in the config.php so you didn't have to change it. Nice. You could also set it up for your pilots to bid on the flights right there instead of going through schedule search but of course if they're logged in. 1 Quote
HighFlyerPL185 Posted January 28, 2013 Author Report Posted January 28, 2013 Nice. You could also set it up for your pilots to bid on the flights right there instead of going through schedule search but of course if they're logged in. Nice idea, quite easy to do. The task above is a bit harder though Quote
Moderators Parkho Posted January 28, 2013 Moderators Report Posted January 28, 2013 Nothing's hard to do in my opinion. There is always a solution to the task one intend to do. Quote
HighFlyerPL185 Posted January 28, 2013 Author Report Posted January 28, 2013 Nothing's hard to do in my opinion. There is always a solution to the task one intend to do. I suppose, I'm just a newbie to PHP and henceforth queries and statements like foreach are still beyond me. To put it bluntly, I haven't done much so far to develop that knowledge Quote
mischka Posted January 28, 2013 Report Posted January 28, 2013 @parkho: Well, normally if you click on the flight number on my departure board you get to the flight info page, where logged-in pilots can place a bid I suppose, I'm just a newbie to PHP and henceforth queries and statements like foreach are still beyond me. To put it bluntly, I haven't done much so far to develop that knowledge that's ok... I never did anything with PHP before I started working on phpvms. I kinda learned php because phpvms is written in it and now, 6 months later, my phpvms is very different from the stock phpvms Once I get my VA search engine working, I'll start publishing some of the "add-ons" I made for PHPvms, but until then I think you'll have to crawl the web and learn php yourself or you may try this: http://www.utr-onlin...ware.asp?page=7 1 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.