STARs Posted October 10, 2013 Report Posted October 10, 2013 hello can someone guide me on how to display pireps airline code wise? iv tried using this code but doesnt seem to work. Using ALLPIREPS module. my code: <table width="100%"> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Aircraft</th> <th>Flight Time</th> <th>Submitted</th> </tr> <?php foreach($pireps as $report) { if($report->flightnum =="ABC") ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php } ?> </table> <p></p> <table> <?php if ($index != $count) {?> <td align="left"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo ($index-$index);?>"> <input type="submit" name="submit" value="Previous <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; } if (count($pireps) == $count) { ?> <td align="right"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo $index;?>"> <input type="submit" name="submit" value="Next <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; }?> </table> Quote
Administrators simpilot Posted October 10, 2013 Administrators Report Posted October 10, 2013 Try changing your loop to something like: <?php foreach ($pireps as $report) { if ($report->code == "ABC") { ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php } ?> 1 Quote
STARs Posted October 10, 2013 Author Report Posted October 10, 2013 Try changing your loop to something like: <?php foreach ($pireps as $report) { if ($report->code == "ABC") { ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php } ?> Thank's ill give it a try right away Quote
mseiwald Posted October 10, 2013 Report Posted October 10, 2013 that works: <table width="100%"> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Aircraft</th> <th>Flight Time</th> <th>Submitted</th> </tr> <?php foreach($pireps as $report) { if($report->code == "ABC") { ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php }} ?> </table> <p></p> <table> <?php if ($index != $count) {?> <td align="left"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo ($index-$index);?>"> <input type="submit" name="submit" value="Previous <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; } if (count($pireps) == $count) { ?> <td align="right"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo $index;?>"> <input type="submit" name="submit" value="Next <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; }?> </table> 1 Quote
STARs Posted October 11, 2013 Author Report Posted October 11, 2013 that works: <table width="100%"> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Aircraft</th> <th>Flight Time</th> <th>Submitted</th> </tr> <?php foreach($pireps as $report) { if($report->code == "ABC") { ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php }} ?> </table> <p></p> <table> <?php if ($index != $count) {?> <td align="left"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo ($index-$index);?>"> <input type="submit" name="submit" value="Previous <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; } if (count($pireps) == $count) { ?> <td align="right"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo $index;?>"> <input type="submit" name="submit" value="Next <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; }?> </table> That Helped and worked @SimPilot: Thanks to you too I need a lil more help. Is their any way it displays PIREPs by the flight no wise? like example: Flight Nos: AA449C AA445C AA555 If Flight No Contains C it should display only those that contain C. Awaiting Regards Quote
STARs Posted October 14, 2013 Author Report Posted October 14, 2013 Sorry for the bump again but no one>>??? Quote
mseiwald Posted October 14, 2013 Report Posted October 14, 2013 That should work if (strpos($report->flightnum, 'C') !== false) { echo "whatever you want"; } Quote
STARs Posted October 16, 2013 Author Report Posted October 16, 2013 That should work if (strpos($report->flightnum, 'C') !== false) { echo "whatever you want"; } No not working or may i am unable to make it work can you pls combine the whole code and tell? Quote
mseiwald Posted October 17, 2013 Report Posted October 17, 2013 That code below is working: <table width="100%"> <tr> <th>Flight Number</th> <th>Departure</th> <th>Arrival</th> <th>Aircraft</th> <th>Flight Time</th> <th>Submitted</th> </tr> <?php foreach($pireps as $report) { if(strpos($report->flightnum, 'C') !== false) { ?> <tr> <td><?php echo $report->code . $report->flightnum; ?></td> <td><?php echo $report->depicao; ?></td> <td><?php echo $report->arricao; ?></td> <td><?php echo $report->aircraft . " ($report->registration)"; ?></td> <td><?php echo $report->flighttime; ?></td> <td><?php echo date(DATE_FORMAT, $report->submitdate); ?></td> </tr> <?php }} ?> </table> <p></p> <table> <?php if ($index != $count) {?> <td align="left"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo ($index-$index);?>"> <input type="submit" name="submit" value="Previous <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; } if (count($pireps) == $count) { ?> <td align="right"> <form name="next20" id="next20" action="<?php echo SITE_URL?>/index.php/AllPIREPS/next" method="post"> <input type="hidden" name="start" value="<?php echo $index;?>"> <input type="submit" name="submit" value="Next <?php echo $count;?>" /> </form> </td> <?php } else { echo '<td></td>'; }?> </table> However the pagination wont work correct (same with the other seperation by airline code by the way) because simply it gets just the first 20 from the database and then skips all flights that dont have a C in your flight number. If you dont have a flight with a C in your last 20 flights the first page will show blank....so you need to click next, next, next until you get to the first flight with a C. Better would be to make new functions for those things. Quote
STARs Posted October 27, 2013 Author Report Posted October 27, 2013 Yep that worked the way I wanted I figured out with the 20 flight thing as well. 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.