Jump to content

Display Latest Flown Flight [SOLVED]


Ariel

Recommended Posts

Im trying to display the latest flight details of a pilots last flown flight.

Using this code

<?php echo $report->depicao; ?> <img src="/airplaneicon.png" alt=""> <?php echo $report->arricao; ?>
FLIGHT: <?php echo $report->code . $report->flightnum; ?>
AIRCRAFT: <?php echo $report->aircraft; ?>
DATE SUBMITTED: <?php echo date(DATE_FORMAT, $report->submitdate); ?>

but what i get is this

Screenshot_3.png

The airport ICAOs are correct and so is the flight number but the aircraft and date are either not what i want it to show or wrong. The aircraft assigned to that flight is the second aircraft on the database but i want it to display the aircraft name. As for the date I cant seem to understand where its getting it from if not from the last submitted PIREP.

Can anyone please let me know what im doing wrong!

Very much appreciated and thank you in advance!

Edited by Vanity
Link to comment
Share on other sites

can't remember what type of field the "submitdate" is, but you could try

<?php echo $report->depicao; ?> <img src="/airplaneicon.png" alt=""> <?php echo $report->arricao; ?>
FLIGHT: <?php echo $report->code . $report->flightnum; ?>
AIRCRAFT: <?php echo $report->aircraft; ?>
DATE SUBMITTED: <?php echo date(DATE_FORMAT, strtotime($report->submitdate)); ?>

or if that doesn't work, do a

<?php echo print_r($report); ?>

And post what you have for the field

[submitdate] =>

What I use

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
foreach($pirep as $p) {
echo $p->depicao.' - '.$p->arricao;
echo '<br />';
echo $p->code.$p->flightnum;
echo '<br />';
echo $p->aircraft;
echo '<br />';
echo date(DATE_FORMAT, $p->submitdate);
echo '<br />';
}
?>

Edited by web541
  • Like 1
Link to comment
Share on other sites

can't remember what type of field the "submitdate" is, but you could try

<?php echo $report->depicao; ?> <img src="/airplaneicon.png" alt=""> <?php echo $report->arricao; ?>
FLIGHT: <?php echo $report->code . $report->flightnum; ?>
AIRCRAFT: <?php echo $report->aircraft; ?>
DATE SUBMITTED: <?php echo date(DATE_FORMAT, strtotime($report->submitdate)); ?>

or if that doesn't work, do a

<?php echo print_r($report); ?>

And post what you have for the field

[submitdate] =>

What I use

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
foreach($pirep as $p) {
echo $p->depicao.' - '.$p->arricao;
echo '<br />';
echo $p->code.$p->flightnum;
echo '<br />';
echo $p->aircraft;
echo '<br />';
echo date(DATE_FORMAT, $p->submitdate);
echo '<br />';
}
?>

Hey web541,

Thanks a bunch for responding. I did end up changing the submit date with the first edit you suggested and that did correct the issue regarding the submitdate.

Now for the life of me i couldnt get the aircraft name to appear and though you did post what you use on your site i didnt want to use it with out giving it a few tries with other codes and such...but that was to no avail.

I did, on a side note, used your "spoiler" code and that did the trick and want to thank you for showing your code. I did tweak it alittle just to not have too many echos and but either one works just fine...

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
foreach($pirep as $p) {
echo '
'.$p->depicao.' <img src="/airplaneicon.png" alt=""> '.$p->arricao.' 
FLIGHT: '.$p->code . $p->flightnum.'
AIRCRAFT: '.$p->aircraft.'
SUBMITTED: '.date(DATE_FORMAT, $p->submitdate).'
';
}
?>

All in all thank you for the help. I really appreciate it!! #lifesaver ;)

Link to comment
Share on other sites

Now i did try adding an ELSE section to the code so when a pilot doesnt have any flights (ex. new pilot) it will display something saying that there is no flights but i keep getting a syntax error.

Parse error: syntax error, unexpected 'else' (T_ELSE)

Does the code not allow an else to it?

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
foreach($pirep as $p) {
echo '
'.$p->depicao.' <img src="/lib/skins/vdelta3/img/airplaneicon.png" alt=""> '.$p->arricao.'
FLIGHT: '.$p->code . $p->flightnum.'
AIRCRAFT: '.$p->aircraft.'
SUBMITTED: '.date(DATE_FORMAT, $p->submitdate).'
';
}
else
{
  echo 'THERE IS NO FLIGHTS';
}
?>

Link to comment
Share on other sites

No worries, feel free to use my code on your side, I purely gave it to you as an example

As per your issue above, this should solve the error

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
if(!$pirep) {
echo 'THERE IS NO FLIGHTS';
} else {
foreach($pirep as $p) {
 echo '
 '.$p->depicao.' <img src="/lib/skins/vdelta3/img/airplaneicon.png" alt=""> '.$p->arricao.'
 FLIGHT: '.$p->code . $p->flightnum.'
 AIRCRAFT: '.$p->aircraft.'
 SUBMITTED: '.date(DATE_FORMAT, $p->submitdate).'
 ';
}
}
?>

  • Like 1
Link to comment
Share on other sites

No worries, feel free to use my code on your side, I purely gave it to you as an example

As per your issue above, this should solve the error

<?php
$pirep = PIREPData::getRecentReportsByCount(1);
if(!$pirep) {
echo 'THERE IS NO FLIGHTS';
} else {
foreach($pirep as $p) {
echo '
'.$p->depicao.' <img src="/lib/skins/vdelta3/img/airplaneicon.png" alt=""> '.$p->arricao.'
FLIGHT: '.$p->code . $p->flightnum.'
AIRCRAFT: '.$p->aircraft.'
SUBMITTED: '.date(DATE_FORMAT, $p->submitdate).'
';
}
}
?>

web541,

Worked like a charm. Thank you again...i really appreciate it!! ^_^

  • Like 1
Link to comment
Share on other sites

  • 6 months later...

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