Monday 15 September 2014

css - How can I add more than just one class to table rows in PHP? -


I'm trying to fix somebody else's code. Right now I am working on a dynamically created table and want to add a different class to each other line. As an example, the background of the 1st 3 and 5th line should be white and the second fourth and 6th line should have a brown background.

Can anyone tell me how to add this kind of second category to the code?

I was not sure that the code would be needed for this question - this is part of the table. If this is not enough then please tell me since my php skills are not good, I do not even know What is the need to understand this problem. As it is not mentioned my code is ...

  $ arr = array (); Forex Currency ($ z => $ e) {$ _them [$ e ['id']] = $ e; If (count ($ arr) & lt; 50) {$ res = mysql_query ('SELECT COUNT (*) from forum_ comments` WHERE` id_them` ='. $ E ['id']. ''); $ Line = mysql_fetch_row ($ res); $ Total = $ line [0]; $ Arr [$ e ['id']] = $ total; } And {$ res = mysql_query ('SELECT COUNT (*) from forum_ comments` WHERE` id_them` ='. $ E ['id']. '') ;;;;; $ Line = mysql_fetch_row ($ res); $ Total = $ line [0]; If ($ Total & gt; $ this-> Device-> Array_man_man ($ arr)) {$ arr [$ this- & gt; Tools- & gt; Array_key_ar_man ($ arr)] = $ total; }}} Arsort ($ arr); $ Arr = array_chunk ($ arr, 25, true); If (! ($ _ GET ['p'])) {$ num = (int) $ _GET ['p']; If ($ num == 1) {$ arr = $ arr [0]; } If ($ num> 1) {$ arr = $ arr [1]; }} $ Ret = '& lt; Table class = "forum_bel" & gt; & Lt; Tr class = "forum_tag_title" & gt; & Lt; Th id = "them" & gt; '. L :: Themes () '& lt; / Th & gt; & Lt; Th id = "date" & gt; '. L: Added () '& lt; / Th & gt; & Lt; Th id = "users" & gt; '. L :: guest () '& lt; / Th & gt; & Lt; Th id = "commets" & gt; '. L: Answer () '& lt; / Th & gt; & Lt; Th id = "last" & gt; '. L: Last_Comments () '& lt; / Th & gt; & Lt; / TR & gt; & Lt; Tr class = "empty_td" & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; / TR & gt; ';    

Just use some CSS, it will apply automatically:

 . Your_table tr: nth-child (weird) {background color: # 00000; } .or_table TR: nth-child (even) {background-color: #ffffff; }    

No comments:

Post a Comment