Easiest way to alternate row colors in PHP/HTML?

前端 未结 19 1840
無奈伤痛
無奈伤痛 2020-12-01 03:41

Here\'s a PHP example of mine. Can anyone find a shorter/easier way to do this?


    
19条回答
  •  有刺的猬
    2020-12-01 04:18

    function row_color($cnt,$even,$odd) { 
    echo ($cnt%2) ? "" : ""; 
    } 
    

    How to use:

    $cnt=0;
    while ($row = mysql_fetch_array ($result)) {
    row_color($cnt++,"e0e0e0","FFFFFF");
    }
    

提交回复
热议问题