Edwin Posted March 16, 2012 Report Share Posted March 16, 2012 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 Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 16, 2012 Report Share Posted March 16, 2012 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>'; ?> Quote Link to comment Share on other sites More sharing options...
Edwin Posted March 16, 2012 Author Report Share Posted March 16, 2012 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> Quote Link to comment Share on other sites More sharing options...
Guest lorathon Posted March 16, 2012 Report Share Posted March 16, 2012 What is filling the $stat array? Quote Link to comment Share on other sites More sharing options...
Edwin Posted March 17, 2012 Author Report Share Posted March 17, 2012 What is filling the $stat array? What you mean? Quote Link to comment Share on other sites More sharing options...
Jeff Posted March 17, 2012 Report Share Posted March 17, 2012 What is being shown where the info is supposed to be? Is there an error, blank or what? Quote Link to comment Share on other sites More sharing options...
Moderators Kyle Posted March 17, 2012 Moderators Report Share Posted March 17, 2012 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> Quote Link to comment Share on other sites More sharing options...
Edwin Posted March 19, 2012 Author Report Share Posted March 19, 2012 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. 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.