Jump to content

Recommended Posts

Posted

Maybe the time actually need to be decimalized, so that 15 mins would be 0.25 rather than 1/60*15. I'll try later. Its bloody annoying this isn't it. :angry:

Tell me about it.:rolleyes: What I'm uncertain about is that your aren't using "else". Wouldn't that mean that if 2 conditions were true, they would both be displayed?

Posted

Gents, I have this on my front page now and very nice it looks too!

1 question though, I am looking to change the time so it reflects my own timezone. Someone said you need to go into the php.ini, where can I find this please?

Cheers

Dale

Posted

hello all!

i m using the following code to take the Flight Board but i m getting a warning ! look the code :

<?php 
$query = "SELECT * FROM phpvms_schedules ORDER BY deptime + 0 ASC"; 
$list = DB::get_results($query); 
echo '<h3>Expected Departures - Current Time is '.date('G:i').'</h3>'; 
echo '<table width="90%" border="1">'; 
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 < 5) 
       { 
               $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 / 60 * 15) 
               { 
               echo 'Final Call'; 
               } 

               if(($flight->deptime - date('G:i')) <= 1) 
               { 
               echo 'Proceed to Gate'; 
               } 

  else
               { 
               echo 'Scheduled Departure'; 
               } 
               echo '</td></tr>'; 
               $count++; 
       } 
       } 
} 
echo '</table>';

echo '<h3>Expected Arrivals - Current Time is '.date('G:i').'</h3>'; 
echo '<table width="90%" border="1">'; 
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); 
               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 / 60 * 1) 
               { 
               echo 'Landed'; 
               }

               if(($flight->arrtime - date('G:i')) <= 1 / 60 * 15) 
               { 
               echo 'On Approach'; 
               } 
               else 
               { 
               echo 'On Time'; 
               } 
               echo '</td></tr>'; 
               $count++; 
       } 
       } 
} 
echo '</table>';  
?>

and the worning is this :

Warning: Invalid argument supplied for foreach() in /home/greeceai/public_html/fss/core/templates/acarsmap.tpl on line 8

Warning: Invalid argument supplied for foreach() in /home/greeceai/public_html/fss/core/templates/acarsmap.tpl on line 46

i use the live map tab on the menu... i replace the live map code witht this code and the result is this in picture following

please help me ! Best regards Dimitris

Posted

I am also getting an invalid argument in the foreach but my refer to another file

Expected Departures - Current Time is 23:28

Warning: Invalid argument supplied for foreach() in /home/simaerobatic/domains/forum.simaerobatic.com/htdocs/lib/skins/ObsessBlue/frontpage_main.tpl on line 244

Flight Number Departure Arrival Departure Time Aircraft Status

Expected Arrivals - Current Time is 23:28

Warning: Invalid argument supplied for foreach() in /home/simaerobatic/domains/forum.simaerobatic.com/htdocs/lib/skins/ObsessBlue/frontpage_main.tpl on line 282

Flight Number Departure Arrival Arrival Time Aircraft Status

BR

Thomas

Posted

I suspect it has something to do with the code to prevent a blank board from 2300 to 2359 and the new code. I guess I'll find out in 7 hours. Although simpilot is the one who knows this stuff, if anyone can post the code on the line where the error is reported. I'll take a look. Maybe, I'll get lucky.

  • Administrators
Posted

That error is telling you that the "$list" variable is coming back empty, there is nothing for the foreach command to look at. Do you have any schedules in your DB?

@dimitris - that is the older code as well.

Guest lorathon
Posted

Gents, I have this on my front page now and very nice it looks too!

1 question though, I am looking to change the time so it reflects my own timezone. Someone said you need to go into the php.ini, where can I find this please?

Cheers

Dale

You should be able to set the server time through the php.ini file

I set ours to ZULU using the following inside of the php.ini

date.timezone = "ZULU"

Additional options at http://php.net/timezones

The php.ini file is usually located in the root folder, at least mine is :D.

Posted

What I can't figure out is, if the script is pulling the flight schedule out by time, then why do the times jump around? And also, how can you add the Airline just before the Flight Number so they know what airline the flight belongs to?

Posted

And also, how can you add the Airline just before the Flight Number so they know what airline the flight belongs to?

Here is the code:

<td>'.$flight->code.$flight->flightnum.'</td>

If you want to add the Airline instead of showing the aircraft name:

<td>'.$flight->notes.'</td>

If you want to see how it is set up on my site My link

Posted

That error is telling you that the "$list" variable is coming back empty, there is nothing for the foreach command to look at. Do you have any schedules in your DB?

@dimitris - that is the older code as well.

I had at least 20 flights in database at time of this error

BR

Thomas

Posted

Been playing around and reading some stuff. This is what I have come up with on my site now:

Expected Departures - Current Time is Fri May 28 05:07:30 EDT 2010

and

Expected Arrivals - Current Time is Fri May 28 05:07:30 EDT 2010

This is the the line of code I used:

echo '<h3>Expected Departures - Current Time is '.date('D M j H:i:s T Y').'</h3>';

I still cant get it to say CEST instead of EDT though, cant find the bloody fabled php.ini file lol.

Posted

Got it working to show CEST instead of EDT!! Without going into the php.ini. It iis also showing the correct time for my timezone.

<?php
date_default_timezone_set('Europe/Berlin');
   	$query = "SELECT * FROM phpvms_schedules ORDER BY deptime + 0 ASC";
   	$list = DB::get_results($query);
   	echo '<h3>Expected Departures - Current Time is '.date('D M j H:i:s T Y').'</h3>';

Hope this helps peeps.

  • Like 1
Posted

That error is telling you that the "$list" variable is coming back empty, there is nothing for the foreach command to look at. Do you have any schedules in your DB?

@dimitris - that is the older code as well.

well ok my DB have more than 65 flights... which is the new code ?

Posted

Depending on what setup your host has, try going to your control panel. Look for something that says PHP Configuration. Select central php.ini to be placed in your root directory. Activate those settings. You may find the file is named php.ini.default. Edit the file by finding the time zone setting and change it to Zulu. Save the file and rename it to php.ini. Your system will then be on UTC.

  • Administrators
Posted

well ok my DB have more than 65 flights... which is the new code ?

Do your flights have the departure and arrival fields filled? Have you changed the prefix for your database from the standard "phpvms_"? Try a print_r using the $list variable and see what, if anything at all is coming back.

New Code ->

http://forum.phpvms.net/topic/2811-request-flight-board/page__view__findpost__p__19704

  • Administrators
Posted

What I can't figure out is, if the script is pulling the flight schedule out by time, then why do the times jump around? And also, how can you add the Airline just before the Flight Number so they know what airline the flight belongs to?

The deptime and arrtime fields in the database are not true time fileds, they are varchar. So trying to sort numerically does not work well. If the time was not stored with the : it work better, but that is the nature of the beast. The sort function is looking at the numerical value prior to the non numerical character - ie the 12 of 12:35, the 35 is ignored. So, when the sort comes out with all the schedules with a 12 prior to the : it sorts them in their order in the database as a secondary sort. What you can do to fix it is go in the schedules database and erase your schedules, then input them in the order of times. It would take some work to keep the order correct that both the deptime and arrtime fields were in the correct order to display in order on your site.

Posted

Got it working to show CEST instead of EDT!! Without going into the php.ini. It iis also showing the correct time for my timezone.

How were you able to get the 3 different items for status (Departed, on-time...etc)?

Posted

So just to confirm.....this has nothing to do with live flights, right?! Just for displaying what would be going on in your schedule if it was really happenning?! Just so I tell my users the correct info. Works good, btw. :)

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