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 Link to comment https://forums.phpfreaks.com/topic/192423-table-row-colour-change/ 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 Link to comment https://forums.phpfreaks.com/topic/192423-table-row-colour-change/#findComment-1013887 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++; } Link to comment https://forums.phpfreaks.com/topic/192423-table-row-colour-change/#findComment-1013891 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? Link to comment https://forums.phpfreaks.com/topic/192423-table-row-colour-change/#findComment-1013902 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 Link to comment https://forums.phpfreaks.com/topic/192423-table-row-colour-change/#findComment-1013954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.