jaymc Posted November 12, 2006 Share Posted November 12, 2006 Basically, to jump straight into my questionI want to have a loop that will echo out a set of <TR><TD>TEXT</TD></TR> for each element in the loopThat is fine, however, I want to have every 1,3,5,7,9,11,13 etc etc .. 21,23,25 background colour of the TD to be different than every 2,4,6,8,10,12 etcWhat is the best way to achieve thisI thought maybe if inside the loop I have basicallyif ($i is odd) {then do this colour}else if ($i is even) {then do this colour}Obviously not syntaxically correct but you get my pointIs that the best way? If so, how do I disdinguish an odd number from an even number? Link to comment https://forums.phpfreaks.com/topic/26973-changing-row-colours/ Share on other sites More sharing options...
Skatecrazy1 Posted November 12, 2006 Share Posted November 12, 2006 [url=http://www.phpfreaks.com/tutorials/5/0.php]http://www.phpfreaks.com/tutorials/5/0.php[/url] Link to comment https://forums.phpfreaks.com/topic/26973-changing-row-colours/#findComment-123325 Share on other sites More sharing options...
doni49 Posted November 12, 2006 Share Posted November 12, 2006 [quote author=jaymc link=topic=114681.msg466666#msg466666 date=1163292116]Is that the best way? If so, how do I disdinguish an odd number from an even number?[/quote]Here's a coulple methods to find out if one number is a multiple of another number.In this case, you're wanting to know if one number is a multiple of 2 (even is a multiple of 2).http://www.phpfreaks.com/forums/index.php/topic,114214.0.html Link to comment https://forums.phpfreaks.com/topic/26973-changing-row-colours/#findComment-123339 Share on other sites More sharing options...
jaymc Posted November 12, 2006 Author Share Posted November 12, 2006 Thanks for both your comments!Ive got it sorted now Link to comment https://forums.phpfreaks.com/topic/26973-changing-row-colours/#findComment-123342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.