Orionsbelter Posted February 17, 2010 Share Posted February 17, 2010 Hi there what is it call and how do i do it? when i loop a table for example i have a inbox which has a table where each mail i have in my inbox is a new row added to the table however i have seen some people are able to set the background color to say black then the next row is red then black then red etc... How would i go about this? Thank you for reading Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 you keep a counter of your rows, and set background colour according to odd or even count Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 so you have something like this $i = 0; // initialise your counter while(......) - however you are getting your rows { $bgcol = ($i % 2)?'#fff':'#ccc'; echo '<tr style="background-color:'.$bgcol.'"> . . . . $i++; } Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted February 17, 2010 Author Share Posted February 17, 2010 Thank you for this sir, may i ask what this is called for future reference? Quote Link to comment Share on other sites More sharing options...
jl5501 Posted February 17, 2010 Share Posted February 17, 2010 I would call it alternate row background colouring to improve readability Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.