Jump to content

[SOLVED ]problem with my code


mattia

Recommended Posts

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 :)

post-2342-072562000 1328900989_thumb.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Administrators

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'));

Link to comment
Share on other sites

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)

post-2342-019962400 1329183087_thumb.png

Link to comment
Share on other sites

  • Administrators

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.

Link to comment
Share on other sites

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

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