note 70972 deleted from language.operators.arithmetic by hholzgra

From: Date: Thu, 02 Aug 2012 15:05:50 +0000
Subject: note 70972 deleted from language.operators.arithmetic by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-189809@lists.php.net to get a copy of this message
Note Submitter: sean at somethinglikemedia dot com ---- An easier way of doing alternating row colors is just setting the first row color outside of your loop, calling your loop, and then calling the class or hex code into a single spot, rather than re-creating the entire div both times. Something like this: <?php $class = "odd"; for ($i = 1; $i <= 10; $i++) { echo "<div class=\"".$class."\">".$i."</div>"; if ($class == "odd") { $class = "even"; } else { $class = "odd"; } } ?>

« previous php.notes (#189809) next »