Jeff Posted July 12, 2010 Report Posted July 12, 2010 I'm trying to show a table of the 5 recent flights flown, and keep running into a brick wall here. Can someone please post the code to show the last 5 flight. Flight Number - Departure Airport - Arrival Airport - Flight Time - Pilot - Landing % Quote
Guest lorathon Posted July 12, 2010 Report Posted July 12, 2010 Here you go <?php MainController::Run('PIREPS', 'RecentFrontPage', 5); ?> or to just get the data <?php $count = 5; $pireps = PIREPData::getRecentReportsByCount($count); ?> Quote
Jeff Posted July 12, 2010 Author Report Posted July 12, 2010 Jeff, I'm trying to create a table to place under the map on my home page that shows the last 5 flights flown. kind of like the one on this page The one that says latest arrivals. Quote
Guest lorathon Posted July 13, 2010 Report Posted July 13, 2010 (edited) try this <?php $count = 5; $pireps = PIREPData::getRecentReportsByCount($count); ?> <table> <thead> <tr> <th>Flight #</th> <th>Departure</th> <th>Arrival</th> <th>Duration</th> <th>Pilot</th> <th>Landing Rate</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>'.$pirep->code.$pirep->flightnum.'</td>'; echo '<td>'.$pirep->depicao.'</td>'; echo '<td>'.$pirep->arricao.'</td>'; echo '<td>'.$pirep->flighttime.'</td>'; echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>'; echo '<td>'.$pirep->landingrate.'</td>'; echo '</tr>'; } } else { echo '<tr><td>There are no recent flights!</td></tr>'; } ?> </tbody> </table> Edited January 26, 2011 by lorathon EDITED to repair code - Code is 100% Quote
Jeff Posted July 13, 2010 Author Report Posted July 13, 2010 Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /home/oneworld/public_html/lib/skins/crystal-II/frontpage_main.tpl on line 61 This is line 61echo "</tr>"; Quote
Guest lorathon Posted July 13, 2010 Report Posted July 13, 2010 I fixed the above code. Missing a semi-colon on the line above. Sorry about that. echo "<td>'.$pirep->landingrate.'</td>"; Quote
Jeff Posted July 13, 2010 Author Report Posted July 13, 2010 Parse error: syntax error, unexpected $end in /home/oneworld/public_html/lib/skins/crystal-II/frontpage_main.tpl on line 162 This is line 162 </div> Here is the whole code for that page <div id="mainbox"> <h3>Welcome To One World Virtual</h3> <?php // Show the News module, call the function ShowNewsFront // This is in the modules/Frontpage folder MainController::Run('News', 'ShowNewsFront', 5); ?> <?php $flights = PIREPData::getRecentReportsByCount(15); $string = ""; foreach($flights as $flight) { $string = $string.$flight->depicao.'+-+'.$flight->arricao.',+'; } ?> <table> <tr> <th>LAST 15 FLIGHT LEGS</th> </tr> <tr> <td><p align="center"><img src="http://www.gcmap.com/map?P=<?php echo $string ?>&MS=bm&MR=240&MX=690x360&PM=pemr:diamond7:red%2b%22%25I%22:red&PC=%230000ff" /><br /> Maps generated by the <a href="http://www.gcmap.com/">Great Circle Mapper</a> - copyright © <a href="http://www.kls2.com/~karl/">Karl L. Swartz</a>.</p></td> </tr> </table> <?php $count = 5; $pireps = PIREPData::getRecentReportsByCount($count); ?> <table> <thead> <tr> <th>Flight #</th> <th>Departure</th> <th>Arrival</th> <th>Duration</th> <th>Pilot</th> <th>Landing Rate</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>'.$pirep->code.$pirep->flighnum.'</td>"; echo "<td>'.$pirep->depicao.'</td>"; echo "<td>'.$pirep->arricao.'</td>"; echo "<td>'.$pirep->flighttime.'</td>"; echo "<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>"; echo "<td>'.$pirep->landingrate.'</td>"; echo "</tr>"; } } else { echo "<tr><td>There are no recent flights!</td></tr>"; ?> </tbody> </table> </div> </div> <div id="sidebar"> <h3>Pilot Center</h3> <?php /* Quick example of how to see if they're logged in or not Only show this login form if they're logged in */ if(Auth::LoggedIn() == false) { ?> <form name="loginform" action="<?php echo url('/login'); ?>" method="post"> <p>Log in to your pilot center or <a href="<?php echo url('/registration'); ?>">register</a><br /> <input type="text" name="email" value="Email/Pilot ID" onClick="this.value=''" /> </p> <p> <input type="password" name="password" value="Password" /> </p> <p> <input type="hidden" name="remember" value="on" /> <input type="hidden" name="redir" value="index.php/profile" /> <input type="hidden" name="action" value="login" /> <input type="submit" name="submit" value="Log In" /> </p> </form> <p> <?php } /* End the Auth::LoggedIn() if */ else /* else - they're logged in, so show some info about the pilot, and a few links */ { /* Auth::$userinfo has the information about the user currently logged in We will use this next line - this gets their full pilot id, formatted properly */ $pilotid = PilotData::GetPilotCode(Auth::$userinfo->code, Auth::$userinfo->pilotid); ?> <strong>Pilot ID: </strong> <?php echo $pilotid ; ?> <strong>Rank: </strong><?php echo Auth::$userinfo->rank;?><br /> <strong>Total Flights: </strong><?php echo Auth::$userinfo->totalflights?>, <strong>Total Hours: </strong><?php echo Auth::$userinfo->totalhours;?> <br /><?php } /* End the else */ ?> </p> <p> <?php MainController::Run('Mail', 'checkmail'); ?> </p> <h3>Recent Reports</h3> <?php MainController::Run('PIREPS', 'RecentFrontPage', 5); ?> <h3>Newest Pilots</h3> <p> <?php MainController::Run('Pilots', 'RecentFrontPage', 5); ?> </p> <h3>Airline Stats</h3> <p><strong>Total Schedules: </strong><?php echo StatsData::totalschedules(); ?></p> <p><strong>Total Aircraft: </strong><?php echo StatsData::TotalAircraftInFleet(); ?></p> <p><strong>Total Pilots: <?php echo StatsData::PilotCount(); ?></strong></p> <p><strong>Miles Flown: </strong><?php echo StatsData::TotalMilesFlown(); ?></p> <p><strong>Total Flights Flown: </strong><?php echo StatsData::TotalFlights(); ?></p> <p><strong>Total Hours Flown: </strong><?php echo StatsData::TotalHours(); ?></p> <p><strong>Passengers Carried: </strong><?php echo StatsData::TotalPaxCarried(); ?></p> <p><strong>Fuel Burned (lbs.): </strong><?php echo StatsData::TotalFuelBurned(); ?></p> <p><strong>Avg Landing Rate: </strong><?php echo ''.round(TouchdownStatsData::airline_average('airline'), 2); ?></p> <p><strong>Total Flights Today: </strong><?php echo StatsData::totalflightstoday(); ?></p> <p><strong>Total Cargo Carried: </strong><?php echo StatsData::TotalCargoCarried(); ?> <h3>Users Online</h3> <?php foreach($usersonline as $pilot) { echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo PilotData::GetPilotCode($pilot->code, $pilot->pilotid). ' ' .$pilot->firstname . ' ' . $pilot->lastname; echo "</p>"; } ?> <br /> Have <?php echo count($usersonline);?> Pilots Online. <h3 class="style3">Guests Online </h3> <p class="txt-red10"> Have <?php echo count($guestsonline);?> Guests Online.</div> </div> Quote
Guest lorathon Posted July 13, 2010 Report Posted July 13, 2010 After this echo "<tr><td>There are no recent flights!</td></tr>"; I forgot to close the else } I will repair the original code Quote
Jeff Posted July 13, 2010 Author Report Posted July 13, 2010 Yep that works, thanks again Jeff. All I need to do now is skin it... Quote
Guest lorathon Posted July 14, 2010 Report Posted July 14, 2010 @ Gabriel I modified my original post so the code there is correct. It is just a simple table for the 5 most recent flights. Quote
llju1 Posted July 15, 2010 Report Posted July 15, 2010 I can not get this to show the full flight Number. As we have 5 Wings(Airlines) it only show the letters of the Wings(Airlines) but not the actual flight number. EX. VMC1001 just will show as VMC or 57V0401-1 will only show 57V. any Ideas? thanks Quote
Guest lorathon Posted July 15, 2010 Report Posted July 15, 2010 I can not get this to show the full flight Number. As we have 5 Wings(Airlines) it only show the letters of the Wings(Airlines) but not the actual flight number. EX. VMC1001 just will show as VMC or 57V0401-1 will only show 57V. any Ideas? thanks Try it on more time. I had a type on the flightnum call. Original code is repaired again Quote
TAV1702 Posted January 26, 2011 Report Posted January 26, 2011 Hi guys. I know this post is real old and I hate to necro post, but I must. I have been itching to add this for a long time but never got around to it. I used the code posted above and it shows up on my site but with some errors. When it outputs the data to the table it shows up like this : I have been trying to fix it, but not sure what is going on. Would love some guiding light. Thanks in advance. Ray Quote
TAV1702 Posted January 26, 2011 Report Posted January 26, 2011 Fixed! I got rid of all the " and replaced with ' . Now I want to get rid of the landing rate and add Status. So it would show Pending, Accepted, Rejected etc,etc. I tried nabbing the code from the viewall_pireps.tpl but it just tossed me out a syntax error. Here is the code tossing the error at me. It is the first div line where it says accepted. Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/xxxxxx/public_html/xxxxxx/lib/skins/brilliancev1/frontpage_main.tpl on line 87 <?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><center>'.$pirep->code.$pirep->flightnum.'</center></td>'; echo '<td><center>'.$pirep->depicao.'</center></td>'; echo '<td><center>'.$pirep->arricao.'</center></td>'; echo '<td><center>'.$pirep->flighttime.'</center></td>'; echo '<td><center>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</center></td>'; echo '<td><?php if($pirep->accepted == PIREP_ACCEPTED) echo '<div id="success">Accepted</div>'; elseif($pirep->accepted == PIREP_REJECTED) echo '<div id="error">Rejected</div>'; elseif($pirep->accepted == PIREP_PENDING) echo '<div id="error">Pending</div>'; elseif($pirep->accepted == PIREP_INPROGRESS) echo '<div id="error">In Flight</div>'; ?></td>'; echo '</tr>'; } } else { echo '<tr><td>There are no recent flights!</td></tr>'; } ?> It is no biggie if I do not get it to work since it is on a dev site only, but would be real nice to get the flight status to work. And please do ignore all of the center and end center tags. I know they are not right. I just hadn't got to do it the right way yet. Quote
Administrators simpilot Posted January 26, 2011 Administrators Report Posted January 26, 2011 You have an extra set of php tags in the file echo '<td><?php and ?></td>'; Quote
Guest lorathon Posted January 26, 2011 Report Posted January 26, 2011 I also changed the original code to single quotes. Not sure why I put the doubles in there. Brain Fart? Quote
TAV1702 Posted January 26, 2011 Report Posted January 26, 2011 You have an extra set of php tags in the file echo '<td><?php and ?></td>'; I got rid of the extra stuff you suggested and I still get the same exact error. Quote
TAV1702 Posted January 26, 2011 Report Posted January 26, 2011 I also changed the original code to single quotes. Not sure why I put the doubles in there. Brain Fart? Oh stuff like that happens from time to time eh? No biggie. Was a quick easy fix. Quote
TAV1702 Posted January 28, 2011 Report Posted January 28, 2011 Anyone got a working copy of this they would care to share? Meaning just for flight status. I got all the rest of it working smoothly. I don't need the touchdown rate so I scrapped it in hopes of getting the flight status in there instead. Like Accepted, pending, Rejected. Quote
Guest lorathon Posted January 28, 2011 Report Posted January 28, 2011 <?php $count = 5; $pireps = PIREPData::getRecentReportsByCount($count); ?> <table> <thead> <tr> <th>Flight #</th> <th>Departure</th> <th>Arrival</th> <th>Duration</th> <th>Pilot</th> <th>Status</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); if($pirep->accepted == '0') $status = 'PENDING'; if($pirep->accepted == '1') $status = 'ACCEPTED'; else $status = 'REJECTED'; echo '<tr>'; echo '<td>'.$pirep->code.$pirep->flightnum.'</td>'; echo '<td>'.$pirep->depicao.'</td>'; echo '<td>'.$pirep->arricao.'</td>'; echo '<td>'.$pirep->flighttime.'</td>'; echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>'; echo '<td>'.$status.'</td>'; echo '</tr>'; } } else { echo '<tr><td>There are no recent flights!</td></tr>'; } ?> </tbody> </table> Quote
TAV1702 Posted January 28, 2011 Report Posted January 28, 2011 Lorathon, I thank you with everything I have to thank you with! Works great. Quote
Chaz Posted February 1, 2011 Report Posted February 1, 2011 Just a quick question as I'm not a php wiz... Is it possible to make the 'Flight#' field a link to view the actual pirep? I've tried using a <a href= but it keeps throwing up errors as I'm not sure how or where to place it in the data string. Cheers! Quote
Moderators mark1million Posted February 1, 2011 Moderators Report Posted February 1, 2011 Yes just research how to html out of the script tag, take a look elsewhere on your site, its there in lots of placed Quote
Guest lorathon Posted February 1, 2011 Report Posted February 1, 2011 With link to pirep report on flight number. <?php $count = 5; $pireps = PIREPData::getRecentReportsByCount($count); ?> <table> <thead> <tr> <th>Flight #</th> <th>Departure</th> <th>Arrival</th> <th>Duration</th> <th>Pilot</th> <th>Status</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); if($pirep->accepted == '0') $status = 'PENDING'; if($pirep->accepted == '1') $status = 'ACCEPTED'; else $status = 'REJECTED'; echo '<tr>'; echo '<td><a href="'.SITE_URL.'/index.php/pireps/viewreport/'.$pirep->pirepid.'">'.$pirep->code.$pirep->flightnum.'</a></td>'; echo '<td>'.$pirep->depicao.'</td>'; echo '<td>'.$pirep->arricao.'</td>'; echo '<td>'.$pirep->flighttime.'</td>'; echo '<td>'.$pilotid.' '.$pilotinfo->firstname.' '.$pilotinfo->lastname.'</td>'; echo '<td>'.$status.'</td>'; echo '</tr>'; } } else { echo '<tr><td>There are no recent flights!</td></tr>'; } ?> </tbody> </table> Quote
Chaz Posted February 1, 2011 Report Posted February 1, 2011 That's brilliant - thanks! What was throwing me was the apostrophies ( ' ) - I just couldn't seem to get the href in the right place! Must be nice to be able to know php... Thanks again! 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.