Jump to content

display pireps airline wise


STARs

Recommended Posts

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>

Link to comment
Share on other sites

  • Administrators

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 } ?>

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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