Web Analytics Made Easy -
StatCounter two kinds of collors table cell - CodingForum

Announcement

Collapse
No announcement yet.

two kinds of collors table cell

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • two kinds of collors table cell

    http://download.aquafold.com/screens...ble-editor.gif

    see that table? one row is skyblue and the next is white, and it goes on...

    anyway, i've thought of many ways for doing this in PHP (displaying mysql records), but what is the quickest and best way for doing this...?

  • #2
    Read this

    http://www.devtek.org/tutorials/alte...row_colors.php

    Code:
    <?php
    
    $myArray = array("Dave","Bill","Brian","Mike","Jason","Eric","Phil","Ben","Chris","Larry"); # Our table fill data
    
    $i = 1; # Our row counter
    ?>
    
    <p>Here's our table with alternating row colors. The second column is the row
       number for your reference.</p>
    
    <table align="left" width="25%" cellpadding="3" cellspacing="0">
    
    <?php
    
    foreach ($myArray as $row)
    {
      if ($i % 2 != 0) # An odd row
        $rowColor = "green";
      else # An even row
        $rowColor = "orange";
      
      echo '<tr bgcolor="' . $rowColor . '"><td align="left"><font color="white"><b>' . $row . '</b></font></td><td align="right"><font color="white"><b>' . $i . '</b></font></td></tr>' . "\r\n";
      $i++; # Increment our row counter
    }
    
    ?>
    
    </table>
    edit: code for the lazy!

    Comment

    Working...
    X