View Full Version : table highlighting
DeadlySin3
11-23-2002, 04:04 PM
As i've mentioned before, i'm writing a Tag Board script. What i'd like to do, is for every other post, I want to add a table around it, and highlight it to a light gray/silver - i'm unsure how to even do this. Any links to resources or code snippets are greatly appreciated!
Btw.. I'm using a flat .txt file for data storage, not a database, if that makes any difference at all
Grizzly
11-23-2002, 04:21 PM
Just use a counter as you loop through the records. If the counter is even, display one bgColor, if the counter is odd, display a different one.
For example, if you're using a for-loop to display the table rows, and the for-loop counter is $i, you could say:
<tr bgColor="<?=($i%2)?"#ffffff":"#efefef";?>">
In English that's saying, if the remainder of $i divided by 2 equals 1, make the bgColor white, otherwise, make it grey.
That's usually how I do it.
DeadlySin3
11-23-2002, 04:33 PM
aha! I was just about to come back and edit my post asking about a counter that would count up to two, then after the second execution, resets back to one.. and do it that way, but your way seems to make more sense. lol.
Don't mind me.. i've been up for about 36 hrs. :x
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.