Ariel Posted July 31, 2016 Report Share Posted July 31, 2016 (edited) 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 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 July 31, 2016 by Vanity Quote Link to comment Share on other sites More sharing options...
web541 Posted July 31, 2016 Report Share Posted July 31, 2016 (edited) 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 July 31, 2016 by web541 1 Quote Link to comment Share on other sites More sharing options...
Ariel Posted July 31, 2016 Author Report Share Posted July 31, 2016 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 Quote Link to comment Share on other sites More sharing options...
Ariel Posted July 31, 2016 Author Report Share Posted July 31, 2016 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'; } ?> Quote Link to comment Share on other sites More sharing options...
web541 Posted July 31, 2016 Report Share Posted July 31, 2016 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).' '; } } ?> 1 Quote Link to comment Share on other sites More sharing options...
Ariel Posted July 31, 2016 Author Report Share Posted July 31, 2016 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!! 1 Quote Link to comment Share on other sites More sharing options...
RamiAbouZahra Posted February 14, 2017 Report Share Posted February 14, 2017 Just out of curiosity, what will the html code be? 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.