Jump to content

touchdown statistics


Edwin

Recommended Posts

Hi,

I'm trying to add a color part in the touchdowns, but when i add this code:

echo '<td>'.if($stat->landingrate > -300) echo '<font color="green">'.$stat->landingrate.' ft/m</font>'; elseif($stat->landingrate <= -300)echo '<font color="red">'.$stat->landingrate.' ft/m</font>'.'</td>';

I'm getting this error:

Parse error: syntax error, unexpected T_IF in

Why i put it on a different part of the page outside the <td> </td> it is working, so i'm doing something wrong, but can't figure out what.

Hope someone can help me out.

Edwin

Link to comment
Share on other sites

Guest lorathon

This should work...

<?php
$font = '<font color="green">;
if($stat->landingrate < = -300) $font = '<font color="red">
?>
<td>
   <?php echo $font.$stat->landingrate?> ft/m</font>
</td>

or this....

<?php
echo '<td>';
if($stat->landingrate > -300)
   echo '<font color="green">'.$stat->landingrate.' ft/m</font>';
else
   echo '<font color="red">'.$stat->landingrate.' ft/m</font>;
echo '</td>';
?>

Link to comment
Share on other sites

Sorry, tried them both, but not working :(

I want the landingrate to show as either green for good touchdown or red for a bad touchdown

This is the full table:

<table width="100%" border="1px">

<tr>

<td>Pilot</td>

<td>Aircraft</td>

<td>Arrival Airport</td>

<td>Landing Rate</td>

<td>Date Posted</td>

</tr>

<?php

foreach($stats as $stat)

{

$pilot = PilotData::getPilotData($stat->pilotid);

$aircraft = OperationsData::getAircraftInfo($stat->aircraft);

echo '<tr>';

echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';

echo '<td>'.$aircraft->fullname.'</td>';

echo '<td>'.$stat->arricao.'</td>';

echo '<td>'.$stat->landingrate.'</td>';

echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';

echo '</tr>';

}

?>

</table>

Link to comment
Share on other sites

  • Moderators

Do you have the Data.class connecting to the $stats array. Which module?

Example, should be in the modules or you need to create a data class...

$this->set('stats', SomethingData::getAllLandings());

If you are creating another TPL file or something, you'll need to put in the $stats = TouchdownStatsData::get_all_stats(); to grab the landings.

<table width="100%" border="1px">
<tr>
<td>Pilot</td>
<td>Aircraft</td>
<td>Arrival Airport</td>
<td>Landing Rate</td>
<td>Date Posted</td>
</tr>
<?php
$stats =  TouchdownStatsData::get_all_stats();
foreach($stats as $stat)
{
$pilot = PilotData::getPilotData($stat->pilotid);
$aircraft = OperationsData::getAircraftInfo($stat->aircraft);
echo '<tr>';
echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
echo '<td>'.$aircraft->fullname.'</td>';
echo '<td>'.$stat->arricao.'</td>';
echo '<td>'.$stat->landingrate.'</td>';
echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';
echo '</tr>';
}
?>
</table>

Link to comment
Share on other sites

I tried the following:

<p><strong>Top Touchdown statistics</strong></p>

<table width="100%" border="1px">

<tr>

<td>Pilot</td>

<td>Aircraft</td>

<td>Arrival Airport</td>

<td>Landing Rate</td>

<td>Date Posted</td>

</tr>

<?php

foreach($stats as $stat)

{

$pilot = PilotData::getPilotData($stat->pilotid);

$aircraft = OperationsData::getAircraftInfo($stat->aircraft);

echo '<tr>';

echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';

echo '<td>'.$aircraft->fullname.'</td>';

echo '<td>'.$stat->arricao.'</td>';

<?php$font = '<font color="green">;if($stat->landingrate < = -300) $font = '<font color="red">?>

<td> <?php echo $font.$stat->landingrate?> ft/m</font></td>

echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';

echo '</tr>';

}

?>

</table>

<p><strong>Top Touchdown statistics</strong></p>

<table width="100%" border="1px">

<tr>

<td>Pilot</td>

<td>Aircraft</td>

<td>Arrival Airport</td>

<td>Landing Rate</td>

<td>Date Posted</td>

</tr>

<?php

foreach($stats as $stat)

{

$pilot = PilotData::getPilotData($stat->pilotid);

$aircraft = OperationsData::getAircraftInfo($stat->aircraft);

echo '<tr>';

echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';

echo '<td>'.$aircraft->fullname.'</td>';

echo '<td>'.$stat->arricao.'</td>';

<?phpecho '<td>';if($stat->landingrate > -300) echo '<font color="green">'.$stat->landingrate.' ft/m</font>';else echo '<font color="red">'.$stat->landingrate.' ft/m</font>;echo '</td>';?>

echo '<td>'.date(DATE_FORMAT, strtotime($stat->submitdate)).'</td>';

echo '</tr>';

}

?>

</table>

getting this error: Parse error: syntax error, unexpected '<' in D:\Websites\airwave\core\templates\touchdownstats\touchdownstats_index.tpl on line 30

Note, i used the free module from Simpilot and wanted to tweak it a little to distinct the good landings from the bad landings by coloring them. I thought it was simply adjusting the code to show the colors.

When i copy my original code outside the table, all is working ok.

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