Re: Two color rows in table inside while iteration -- just say no to mod

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Apr 30, 2010, at 4:20 PM, Daevid Vincent wrote:

-----Original Message-----
From: Ashley Sheridan [mailto:ash@xxxxxxxxxxxxxxxxxxxx]

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.

-----Original Message-----
From: Richard Quadling [mailto:rquadling@xxxxxxxxxxxxxx]

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 "<tr class=??????\"alternate-row-".(1 + (++$a%5))."\"><..."
}

giving alternate-row-1, alternate-row-2, alternate-row-3,
alternate-row-4 and alternate-row-5

Okay, how many tables do you EVER see with more than TWO colors? Come on
now.

Show me some URL's to REAL sites (not some contrived examples) that use multiple row colors or fades in a rotating fashion. Not talking about a highlight roll-over, nor am I talking about highlighting rows of certain criteria in different colors, as both of those are not the problem for this solution. I'm talking about a straight up table that cycles each row more
than 2 colors.

99% of your tables are 2 colors, and flipping a bit (i.e. Boolean) is WAY
faster to compute than modulus and also easier to understand.

http://www.youtube.com/watch?v=pXhKzY0BKwY ;-) (I say that out of love!)


A bit of a contrived example... BUT... I could envision having multiple (more then 2) colors on a blog with comments...

Maybe it's a patriotic blog and they want the comments to cycle between red, white & blue... (Or your countries colors) And yes I know that you could assume white is a default... But I know some people who have the default color of their web browser set to bright pink to point out where rules aren't specifically assigned :)

And unless we are adding a multiple seconds to the load time is anyone going to notice a difference of 1 second? Or am I wrong?

Also... I'm not trying to start a fight... Just trying to understand the different possibilities and the impact :) Hoping to write the next facebook eventually.... But aren't we all? ;)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux