DELETE ME NOW! Posted April 6, 2009 Posted April 6, 2009 Some people have asked me this on msn. What is Alternate Table Rows? Alternate Tables Rows is like you have a diffrent color for each line of a table/tr *me thinks lol. Example. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Will out put Hello. with the background color red. Hello Again. with the background color blue. How i do it is like. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. How will i do this? on your You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. stuff under it add You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. and then just edit the <tr> to like echo '<tr style="background-color: '. $bgcolor .'">'; I think i have shown what it does, i just wanted to post it because, its doing my head in on msn people asking how to do it lol. Quote
Vali Posted April 6, 2009 Posted April 6, 2009 Re: Alternate Table Rows You can use jQuery for this: #1 you render your HTML normally. #2 you create some css: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. #3 you add some javascript: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Now all the tables of the class "zebra" will have alternating colors. No need for anything in the PHP code for the display. Quote
DELETE ME NOW! Posted April 6, 2009 Author Posted April 6, 2009 Re: Alternate Table Rows You can use jQuery for this: #1 you render your HTML normally. #2 you create some css: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. #3 you add some javascript: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Now all the tables of the class "zebra" will have alternating colors. No need for anything in the PHP code for the display. I have neva used jQuery thanks :) for the tip also :D Quote
Dave Posted April 6, 2009 Posted April 6, 2009 Re: Alternate Table Rows jQuery comfuses me to much so i'll think i use the PHP method :). Thanks Crazy-T Quote
SaMz Posted April 6, 2009 Posted April 6, 2009 Re: Alternate Table Rows You can use jQuery for this: #1 you render your HTML normally. #2 you create some css: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. #3 you add some javascript: You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. Now all the tables of the class "zebra" will have alternating colors. No need for anything in the PHP code for the display. jQuery is a very good way of doing it Quote
Raptor_Jesus Posted April 6, 2009 Posted April 6, 2009 Re: Alternate Table Rows another quick and easy method .row-even{ background-color: #C0C0C0; } .row-odd{ background-color: #D8D8D8; } then before your where $toggle = 1; after $toggle *= -1; $style = $toggle < 0 ? 'row-even' : 'row-odd'; apply to the following <tr class='$style' > Quote
DELETE ME NOW! Posted April 6, 2009 Author Posted April 6, 2009 Re: Alternate Table Rows another quick and easy method .row-even{ background-color: #C0C0C0; } .row-odd{ background-color: #D8D8D8; } then before your where $toggle = 1; after $toggle *= -1; $style = $toggle < 0 ? 'row-even' : 'row-odd'; apply to the following <tr class='$style' > Ya or like my way but diff. same css^^^ $style = ($style == "row-even") ? "row-odd" : "row-even"; <tr class="'. $style .'"> lol Quote
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.