Jump to content

[SOLVED] table row colour


verN

Recommended Posts

I have a table and would like the row to change colours. The table uses two colours white and green. The frist row in the table should be green then white then green then white and so on.

 

How would i go about doing this thanks. I am using while() tio get the rows and storing it in a variable

 

thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/46844-solved-table-row-colour/
Share on other sites

Guest prozente

tauchai83, one thing about your approach is the more rows you go through the more memory would be taken by PHP as the variable got larger.

 

Aside from this you may also try shortening your code by using

 

echo "\n<tr bgcolor='".(($row_counter%2==0) ? 'green' : 'white' )."'>\n";

 

instead of the if statement

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.