RE: [PHP] RE: newbie alternate row colours in dynamic table

From: Date: Sat, 05 Apr 2003 23:12:27 +0000
Subject: RE: [PHP] RE: newbie alternate row colours in dynamic table
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142544@lists.php.net to get a copy of this message
At 00:42 6-4-2003, you wrote:
Wow you guys are going about that way more complicated than it needs to be: $i = 0; echo "<TR BGCOLOR='#". (($i++ % 2 == 0) ? "'E3E3E3" : "FFFFFF") ."'>"; Then it just alternates and takes care of itself (plus you get a nice little index counter as well as a bonus if you want to use $i DÆVID.
Or in my belief even faster, (without the bonus): $i = TRUE; {$i=!$i; echo "<TR BGCOLOR='#". (($i) ? "'E3E3E3" : "FFFFFF") ."'>"; } Since your code has these steps: 1. increment $i 2. divide $i by 2 and keep the remains 3. compare remains with 0 4. make the true/false decision And the TRUE type: 1. toggle boolean 4. make the true/false decision

« previous php.general (#142544) next »