Jump to content

Last flight table


stephanepa38

Recommended Posts

Hello

I would like to put on my ftp servor a table which presents the pilot list with only the date of the last flight. This page will be public, so all the people will see it without registering.

I tried to do this php page with this code I found in this forum :

<?php

$report = PIREPData::GetLastReports($pilot->pilotid, 1);

echo date('d.M.Y', strtotime($report->submitdate));

?>

But when I use this code, nothing happens.

How can I do to do this page with only the pilot list and the date of the last flight ?

Thanks

Stéphane

Link to comment
Share on other sites

  • Administrators

If you want to do a little more with it since if a pilot has not flown any flights the system returns a date of Dec 31 1969 you could use the code below to show "No Flights" instead of the old date..

<?php
$report = PIREPData::GetLastReports($pilot->pilotid, 1);
$check = date('Y', strtotime($report->submitdate));
if ($check=="1969")
	{
	echo 'no flights';
	} 
	else
	{
	$last = date('M.d.Y', strtotime($report->submitdate));
	echo $last;
	}				
?>

Link to comment
Share on other sites

  • Administrators

The last PIREP date is stored in the pilot's table, in the 'lastpirep' field, as a datetime, so you could do:

<?php

$pilots = PilotData::GetAllPilots();

foreach($pilots as $pilot)
{
    echo "{$pilot->firstname} {$pilot->lastname} - {$pilot->lastpirep}<br />";
}

When using double quotes in a string, it's good practice to encapsulate variables in { }

You can check if it's null (this is the default value, it's only updated when there's a PIREP):

if($pilot->lastpirep == '0000-00-00 00:00:00')
{
    echo 'No PIREP';
}
else
{
    // What David suggested:
    echo  date('m-d-Y', strtotime($pirep->lastpirep));
}

This will be the most reliable way.

Also, not sure if you knew, if this is outside of phpVMS, you have to:

<?php

include '/path/to/core/codon.config.php';

Then anything with the API should work.

Link to comment
Share on other sites

Hello

Thank you for your ansers. I put this code on an lastflight.php page in my ftp servor, but outside of the phpvms folder :

<?php

include '/path/to/core/codon.config.php';

$pilots = PilotData::GetAllPilots();

foreach($pilots as $pilot)
{
    echo "{$pilot->firstname} {$pilot->lastname} - {$pilot->lastpirep}<br />";
}

if($pilot->lastpirep == '0000-00-00 00:00:00')
{
    echo 'No PIREP';
}
else
{
    // What David suggested:
    echo  date('m-d-Y', strtotime($pirep->lastpirep));
}
?>

But I still have a blank page (without any information) when I want to see this page with only this code.

Did I make an error ?

Thanks

Stéphane

Link to comment
Share on other sites

Now, I have this error :

Warning: include() [function.include]: Failed opening '/phpvms/core/codon.config.php' for inclusion (include_path='.') in /home/vol4/byethost31.com/b31_3600827/htdocs/lastflight.php on line 5

Fatal error: Class 'PilotData' not found in /home/vol4/byethost31.com/b31_3600827/htdocs/lastflight.php on line 10

Stéphane

Link to comment
Share on other sites

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