mattia Posted February 10, 2012 Report Posted February 10, 2012 hi all I wrote this code to get the last flight of a pilot <table> <tr> </tr> <TR><TD colspan="5"><hr color="red" size="1"> </TD></TR> <TR><TD colspan="5"><font color=yellow> <font size="3px"><b> Recent Flight Reports </b></font></font> </TD></TR> <TR><TD colspan="5"><hr color="red" size="1"> </TD></TR> <tr> <td><font color=red>Flight N°</td> <td><font color=red>Aircraft</td> <td><font color=red>Submitted</td> <td><font color=red>Flight Time</td> <td><font color=red>Status</td> </tr> <?php $query="SELECT * FROM phpvms_11pireps WHERE pilotid = '$userinfo->pilotid' ORDER BY submitdate DESC LIMIT 13"; $list=DB::get_results($query); foreach ($list as $flight) { echo '<tr><th>'.$flight->code.' <b>'.$flight->flightnum.'</th> <th>'.$flight->aircraft.'</th> <th>'.date(DATE_FORMAT, strtotime($flight->submitdate)).'</th> <th>'.$flight->flighttime.'</th> <th>'.$flight->accepted.'</th> </tr>'; } ?> but when I make $flight->aircraft I get a number of aircraft but not your name The same thing also for flight status. I also tried $flight->aircraftname or $flight->aircraftcode but dont work. how can I get the name of the aircraft and flight status? thanks for help Quote
Jeff Posted February 10, 2012 Report Posted February 10, 2012 Try using <?php echo $pirep->aircraft?> or <?php echo $report->aircraft; ?> Quote
mattia Posted February 10, 2012 Author Report Posted February 10, 2012 hi jeff thanks for your help I tried your code but not work Quote
Jeff Posted February 11, 2012 Report Posted February 11, 2012 This is what you should be using for your Recent Flights Board. <table align="center" border="0" width="100%"> <thead> <tr> <th>Last 10 Flights</font></th></tr> </thead> </table> <?php $count = 10; $pireps = PIREPData::getRecentReportsByCount($count); ?> <table align="center" border="0" width="100%"> <thead> <tr border="0"> <th align="center"><font face='Verdana' size='2' color="#FFFFFF">Pilot</font></th> <th align="center"><font face='Verdana' size='2' color="#FFFFFF">Flight #</font></th> <th align="center"><font face='Verdana' size='2' color="#FFFFFF">Origin</font></th> <th align="center"><font face='Verdana' size='2' color="#FFFFFF">Arrival</font></th> <th align="center"><font face='Verdana' size='2' color="#FFFFFF">Landing Rate</font></th> </tr> </thead> <tbody> <?php if(count($pireps) > 0) { foreach ($pireps as $pirep) { $pilotinfo = PilotData::getPilotData($pirep->pilotid); $pilotid = PilotData::getPilotCode($pilotinfo->code, $pilotinfo->pilotid); echo "<tr>"; echo "<td align=center background='images/tables/board.png'> <font face=Verdana size=2 color=#E8D33D> $pirep->firstname $pirep->lastname </font></td>"; echo "<td align=center background='images/tables/board.png'> <font face=Verdana size=2 color=#E8D33D> $pirep->code $pirep->flightnum </font></td>"; echo "<td align=center background='images/tables/board.png'> <font face=Verdana size=2 color=#E8D33D> $pirep->depname </font></td>"; echo "<td align=center background='images/tables/board.png'> <font face=Verdana size=2 color=#E8D33D> $pirep->arrname </font></td>"; echo "<td align=center background='images/tables/board.png'> <font face=Verdana size=2 color=#E8D33D> $pirep->landingrate ft/min</font></td>"; echo "</tr>"; } } else { echo "<tr><td>There are no recent flights!</td></tr>"; } ?> </tbody> </table> I actually posted a customized table for this somewhere in here about a month ago, you might do some searching for it. You might want to try it, or you can just customize this one to suit your needs. Quote
mattia Posted February 11, 2012 Author Report Posted February 11, 2012 thanks for your code, but this takes all pirep. I need the pirep a single pilot to put in pilot_public_profile: tpl Quote
Moderators joeri Posted February 11, 2012 Moderators Report Posted February 11, 2012 change the part <?php $count = 10; $pireps = PIREPData::getRecentReportsByCount($count); ?> to this <?php $count = 1; $pireps = PIREPData::getRecentReportsByCount($count); ?> schould show 1 pirep now Quote
mattia Posted February 11, 2012 Author Report Posted February 11, 2012 hi joeri and jeff Thanks for your patience, if I use this code takes the last pirep arrived, but I need the last 10 pirep sent a single pilot to put in the pilot_public_profile.tpl sorry for my english I hope I explained myself now Quote
mattia Posted February 12, 2012 Author Report Posted February 12, 2012 in my profile.php have add $this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid)); in my pilot_public_profile.tpl I changed my code like this: <?php foreach($pireps as $flight) { echo '<tr><th>'.$flight->code.' <b>'.$flight->flightnum.'</th> <th>'.$flight->aircraft.'</th> <th>'.date(DATE_FORMAT, strtotime($flight->submitdate)).'</th> <th>'.$flight->flighttime.'</th> <th>'.$flight->accepted.'</th> </tr>'; } ?> but so it takes all pirep, you can take only the top 10? thanks for your help guys Quote
Administrators simpilot Posted February 14, 2012 Administrators Report Posted February 14, 2012 If you are just trying to get the last 10 reports change; $this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid)); to $this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10')); That should return only the last 10 reports, there is also a third parameter available as to the status of the pirep. For example if you just want approved pireps do; $this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10', '1')); Quote
mattia Posted February 14, 2012 Author Report Posted February 14, 2012 hi Dave, many thanks for your help put your code in my profile.php $this->set('pireps', PIREPData::GetLastReports(Auth::$userinfo->pilotid, '10')); and in my pilot_public_profile.tpl write this <?php foreach($pireps as $flight) { echo '<tr><th>'.$flight->code.' <b>'.$flight->flightnum.'</th> <th>'.$flight->aircraft.'</th> <th>'.date(DATE_FORMAT, strtotime($flight->submitdate)).'</th> <th>'.$flight->flighttime.'</th> <th>'.$flight->accepted.'</th> </tr>'; } ?> works but does not give me the name of the aircraft, how do I take the name of the aircraft and the flight status (attach photo) Quote
Administrators simpilot Posted February 14, 2012 Administrators Report Posted February 14, 2012 That is all that is recorded with the pirep, the database id of the aircraft, you are going to have to call the a/c data from the database. <?php foreach($pireps as $flight) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><th>'.$flight->code.' <b>'.$flight->flightnum.'</th> <th>'.$aircraft->name.'</th> <th>'.date(DATE_FORMAT, strtotime($flight->submitdate)).'</th> <th>'.$flight->flighttime.'</th> <th>'.$flight->accepted.'</th></tr>'; }?> The aircraft variable will be filled with all the aircraft info - do a print_r($aircraft) to see what is available. Quote
mattia Posted February 14, 2012 Author Report Posted February 14, 2012 WOOOOWWWWWWWWW MANY THANKS DAVE WORKSSS NOWWW!!!! last pleasure Dave how to convert the status of the flight? 0=approval pending 1=accept 2=reject Quote
Administrators simpilot Posted February 14, 2012 Administrators Report Posted February 14, 2012 Put an if qualifier in there; echo '<th>'; if($flight->accepted == '0'){echo 'Pending';} elseif($flight->accepted == '1'){echo 'Accepted';} elseif($flight->accepted == '2'){echo 'Rejected';} else{echo 'Unknown';} echo '</th></tr>'; Quote
mattia Posted February 14, 2012 Author Report Posted February 14, 2012 i put your code <?php foreach($pireps as $flight) { $aircraft = OperationsData::getAircraftInfo($flight->aircraft); echo '<tr><th>'.$flight->code.' <b>'.$flight->flightnum.'</th> <th>'.$aircraft->name.'</th> <th>'.date(DATE_FORMAT, strtotime($flight->submitdate)).'</th> <th>'.$flight->flighttime.'</th> echo '<th>'; <-------------------this is line 211 if($flight->accepted == '0'){echo 'Pending';} elseif($flight->accepted == '1'){echo 'Accepted';} elseif($flight->accepted == '2'){echo 'Rejected';} else{echo 'Unknown';} echo '</th></tr>'; } ?> but this error appears Parse error: syntax error, unexpected '>' in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/pilot_public_profile.tpl on line 211 Many thanks for help Dave Quote
Administrators simpilot Posted February 14, 2012 Administrators Report Posted February 14, 2012 You need to close line 210 <th>'.$flight->flighttime.'</th> should be <th>'.$flight->flighttime.'</th>'; Quote
mattia Posted February 14, 2012 Author Report Posted February 14, 2012 MANY THANKS DAVE FOR YOUR HELP NOW THE PROBLES IS SOLVED THANKS Quote
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.