Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

table class

Status
Not open for further replies.

iamsw00sh

Programmer
May 21, 2003
92
RO
i have this table

i am going to use it in lots of screens

i would like to make it somehow like using:
1. predefined header (<th is gonna be good i guess>)
2. i would like to use some tr design stuff to make every second row the same color ...
example:

table header is going to be purple
and then first row of data would be white
and then the second row of data would be light purple
and then third row of data would be white
and then the fourth row of data would be light purple

i did this using server side variables until now ...

there has to be something easier ...
is it ..

10x in advance

 
i have an other one

is there any way NOT to use this "odd"-"even" stuff?

i mean i am getting my data from database...

this way i don't know if the TR is odd or is even ...
so i'll have to insert an "if"
and

if odd then class=odd
else (even) class=even

is there a way to do this without this IF?

thanks

 
instead of doing the IF check on the db results for odd or even, do it on the class status. start by initializing the class of the table row to the first color you want (white). then start the loop through the results. after you add the row of data in HTML in the loop, check to see which color it is and then set it to the other one.

kind of like this:


$class='whiterow'
while $row=getDBrow {
html=<tr class=$class><td>$row[data1]</td><td>$row[data2]</td></tr>
if $class='whiterow' then $class='purplerow'
else $class='whiterow'

} end loop


hope that makes sense...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top