<style>
.odd{background-color:red;}
</style>
$c = true;
foreach($posts as $post)
echo '<div'.(($c = !$c)?' class="odd"':'').">$post</div>";
Source: https://stackoverflow.com/questions/399137/easiest-way-to-alternate-row-colors-in-php-html
<style>
.odd{background-color:red;}
</style>
$c = true;
foreach($posts as $post)
echo '<div'.(($c = !$c)?' class="odd"':'').">$post</div>";
Source: https://stackoverflow.com/questions/399137/easiest-way-to-alternate-row-colors-in-php-html