![]() |
Alternate row color ?
Good day to you all,
Here I come again with a piece of code which reach a txt file and return the text, it also convert the "\n" into "<br>". Here it is : PHP Code:
How can I make $lines have alternate row color ? Thanks ! |
You would flip a variable every time the loop is run. For example:
PHP Code:
|
could just do a mod oppr:
PHP Code:
|
There we are !
PHP Code:
|
i found an easy way to do this.
Code:
$cell_color = ($i % 2 == 0 ? "class1" : "class2"); $i++; |
That's definitely the best way, Matt, and the way I always use to do this.
|
1 Attachment(s)
I had a stab at a different approach for doing this without the ternary operator. See what you think to this, as it has support for many colours also.
Code:
<table> |
| All times are GMT. The time now is 05:06 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0