Jump to content

Table colour formatting


Connor1994

Recommended Posts

Hi all,

prob a really easy solution to most but its really getting me now :D

I have:

<?php
if(!$reports)
{
echo 'No reports have been filed';
return;
}



?>

 <table width="100%" cellpadding="4" cellspacing="0">
   <tr align="center">
     <th bgcolor="#f5f5f5"><strong>Pilot</strong></th>
     <th bgcolor="#f5f5f5"><strong>Flight Number</strong></th>
     <th bgcolor="#f5f5f5"><strong>Departure</strong></th>
     <th bgcolor="#f5f5f5"><strong>Arrival</strong></th>
     <th bgcolor="#f5f5f5"><strong>Duration</strong></th>
     <th bgcolor="#f5f5f5"><strong>Aircraft</strong></th>
     <th bgcolor="#f5f5f5"><strong>Landing Rate</strong></th>
   </tr>
   <?php
$rowclass = 0;
foreach($reports as $report)
{
?>
   <tr class="row<?php echo $rowclass ?>" align="center">
    <td align="center" scope="col"><?php echo $report->firstname . ' ' . $report->lastname?></td>
     <td scope="col">XLA<?php echo $report->flightnum; ?></td>
     <td scope="col"><?php echo $report->depicao?></td>
     <td scope="col"><?php echo $report->arricao?></td>
     <td scope="col"><?php echo $report->flighttime; ?></td>
     <td scope="col"><?php echo $report->aircraft?></td>
     <td scope="col"><?php echo $report->landingrate; ?> ft/min</td>

   </tr>
   <?php
$rowclass = 1 - $rowclass;
}
?>
 </table>

But on every latest flight I want one to be one colour the second to be another and for the third to go back to the first e.g

1 - Blue

2 - Green

3 - Blue

4 - Green

How would I go about doing that with that code above? Could I get an example please.

Thanks ;)

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