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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.