From: Richard Quadling on 30 Apr 2010 07:12 On 30 April 2010 08:40, Daevid Vincent wrote:>> -----Original Message----- >> while(foo){ >> \$tr = (0 == \$trColor % 2)? "#E8E8E8" : "#FFFFFF"; >> echo "
a1 a2a3 a4a5
\$row[0]\$row[1] \$row[2]\$row[3]\$row[4]
"; >> ... > > Don't do this modulus (%) math!!!! Just toggle a boolean!! > > "> > The modulus is a good option when there are more than 2 states. Say a 5 row fade ... \$a=0; while (\$row=mysql_fetch_...){ echo "<..." } giving alternate-row-1, alternate-row-2, alternate-row-3, alternate-row-4 and alternate-row-5 -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling From: "Jay Blanchard" on 30 Apr 2010 07:14 [snip] Don't do this modulus (%) math!!!! Just toggle a boolean!! "> [/snip] What is wrong with modulus math???? From: Paul M Foster on 30 Apr 2010 10:34 On Thu, Apr 29, 2010 at 05:34:38PM -0400, tedd wrote: > At 11:01 AM -0300 4/29/10, Juan Rodriguez Monti wrote: >> >> Tedd, >> Thanks. I'm gonna check it. I finally solved it using: >> >> if ( CONDITIONS )) { >> >> \$results = query( QUERY ); >> \$colors = array('#97b7cd','#96bf8c'); >> \$index= 0; >> echo ""; >> echo ""; >> echo ''; >> echo ""; >> echo ""; >> echo '
'; >> >> echo ""; >> echo "
>> >> "; >> >> while (\$row = CONDITIONS )) { >> echo ''; >> echo " >> "; >> } >> echo ""; >> echo ""; >> echo ""; >> echo '

back

'; >> echo ""; >> echo ""; >> >> This solution was the best for me. It's solved with your help. >> >> Thanks a lot!. >> >> Juan > > The above is far more complicated than it has to be. > > Please critically review my example. +1 This thread came up before, and tedd's solution was the least complex, as far as I could tell. I shamelessly stole his code and regularly use it in my own projects. ;-} Paul -- Paul M. Foster From: Ashley Sheridan on 30 Apr 2010 10:30 On Fri, 2010-04-30 at 06:14 -0500, Jay Blanchard wrote: > [snip] > Don't do this modulus (%) math!!!! Just toggle a boolean!! > >
"> > [/snip] > > What is wrong with modulus math???? > Modulus is the most elegant solution I reckon. Imagine if you only needed to highlight every 3rd row, or 4th? Easy to change the modulus for it, not so easy to re-work a binary switch. Thanks, Ash http://www.ashleysheridan.co.uk From: Jay Ess on 30 Apr 2010 10:37 Paul M Foster wrote:> +1 > > This thread came up before, and tedd's solution was the least complex, > as far as I could tell. I shamelessly stole his code and regularly use > it in my own projects. ;-} > Or if one choose to use Smarty template. http://www.smarty.net/manual/en/language.function.cycle.php First  |  Prev  |  Next  |  Last