I think that it's better to user inline style rather than bgcolor (`<td style="background-color: ' . $bgcolor . '; ">`).
the same in lists.php