Jump to content

Changing Row Colours


jaymc

Recommended Posts

Basically, to jump straight into my question

I want to have a loop that will echo out a set of <TR><TD>TEXT</TD></TR> for each element in the loop

That 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 etc

What is the best way to achieve this

I thought maybe if inside the loop I have basically

if ($i is odd) {then do this colour}
else if ($i is even) {then do this colour}

Obviously not syntaxically correct but you get my point

Is 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

[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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.