By drupalfantwo on
Hello,
Forgive me for asking. Please refer me to a link that has a working example on how to produce alternating colors. The links I found so far has information that is too complex for me to comprehend. A simple working sample would really help.
<?php
// I need to know how to make the theme() function produce alternating colors
// with respect to the rows. Red and Blue will do :)
$header= array('rows');
$rows = array(1,2,3,4,5,6,7,8,9,10)
print theme('table',$header,$rows)
?>
Thank you for reading
Comments
It's built in
By default it adds alternating "odd" and "even" classes to the table rows. Just use CSS to assign colours to those classes - no PHP needed.
One problem you have though is that you aren't defining $rows properly. $rows is a array of rows and each row is an array of cells.
eg to create the rows array I think you wanted to create: