Re: that table-row-color-switching thing - again!

From: Date: Sat, 02 Dec 2000 19:40:31 +0000
Subject: Re: that table-row-color-switching thing - again!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28385@lists.php.net to get a copy of this message
What would an entire loop look like?
<? $my_favorite_things = array (
        "color" => "blue",
        "musician" => "Bjork",
        "song" => "New World",
        "os" => "Linux Mandrake",
        "food" => "Pop Tarts",
        "language" => "PHP4");
print "<table>"; while (list($thing, $value) = each ($my_favorite_things))
        {
        $row = 1-$row;
        $color = ($row==0)?"#ffff00":"#00ffff";
        print "<tr bgcolor=$color><td>$thing</td><td>$value</td></tr>";
        }
print "</table>"; ?>
here's the most efficient way I've found to change HTML table row colors as you loop through an array of info:
     $row = 1-$row;
      $color = ($row==0)?"#eeeeee":"#ffffff";


« previous php.general (#28385) next »