Ademar Andrade Posted March 31, 2013 Report Share Posted March 31, 2013 Hi all, I'm trying to determinate witch flights have been done on time. The logic is: if the flight time is bigger than the estimated, the result is Delayed, else On time. So i simple code: <?php if ($pirep->flighttime > $schedules->flighttime) { echo "Delayed"; } else { echo "On time"; } ?> On results, all flights are "Delayed", and it's not truth. Help guys, what is wrong with my code? Thanks for attention! Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted April 1, 2013 Moderators Report Share Posted April 1, 2013 The code looks fine, but do you have the flight time set in your schedules? Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 10, 2013 Report Share Posted April 10, 2013 that can be a reason! and I would try to echo $schedules->flighttime for testing! since I have the strong feeling that it returns nothing (when it have no return) the PIREP flightime is always greater and jumps directly into the echo "Delayed" Kyle, like you said the logical part is correct TESTED! with values I will try to find out what is wrong tonight Quote Link to comment Share on other sites More sharing options...
Ademar Andrade Posted April 10, 2013 Author Report Share Posted April 10, 2013 that can be a reason! and I would try to echo $schedules->flighttime for testing! since I have the strong feeling that it returns nothing (when it have no return) the PIREP flightime is always greater and jumps directly into the echo "Delayed" The code looks fine, but do you have the flight time set in your schedules? Thank you guys... Now is working... Have a nice day! Quote Link to comment Share on other sites More sharing options...
freshJet Posted April 10, 2013 Report Share Posted April 10, 2013 These both use different formats Quote Link to comment Share on other sites More sharing options...
mseiwald Posted April 10, 2013 Report Share Posted April 10, 2013 On my Site i have both times converted to minutes and then the checks.... I extended the range a bit.... if flighttime more than scheduledtime + 15 then it's delayed If flighttime less than scheduledtime - 15 it's early and else it's on time. That works. I can't give the code for it right now as i'm not on my PC but it should be easy to do for you. Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 11, 2013 Report Share Posted April 11, 2013 if you can share the code when you are on your PC again please because I dont know how to convert the values Quote Link to comment Share on other sites More sharing options...
Txmmy83 Posted April 13, 2013 Report Share Posted April 13, 2013 is that how to get it work? http://forum.phpvms.net/topic/7561-flight-delay-or-to-early/#entry50310 Quote Link to comment Share on other sites More sharing options...
mseiwald Posted April 13, 2013 Report Share Posted April 13, 2013 Yeah that works! I have changed it on my site a few Weeks ago but i don't have access to the files for the next week as i'm still on vacation. However the code from the link you posted is also working correct. Quote Link to comment Share on other sites More sharing options...
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.