Adding background color to table rows I was wondering if it is possible to change the background color of a table row.

I want to display certificate files, and if that certificate is going to expire in longer than 30 days the color green would be good. If it is less then 30 days color orange and if it's expired color red.

I tried finding it on the internet but I can't find anything like this.

This is how my current column data looks like.

'c3' =&gt; array(
        'data' =&gt; array('#type' =&gt; 'item', '#markup' =&gt; t('@uploaded', array('@uploaded' =&gt; date('d-m-Y', $val-&gt;upload_date)))),
    ),


I already tried adding '#class' => array('bgcolor' => '#ffffff'), or just 'bgcolor' but that doesn't work.

Thanks in advance!

Complete code

$qry = db_select('push_notifications_api', 'n');
$qry-&gt;join('push_notifications_certificates', 'u', 'n.ios = u.cert_id');
$cert_table = $qry
-&gt;fields('n', array('app_name', 'ios'))
-&gt;fields('u', array('cert_id', 'cert_name', 'upload_date', 'expiration_date'))
-&gt;OrderBy('u.expiration_date', 'ASC')
-&gt;execute();

$form['certificates']['table'] = array(
 '#theme' =&gt; 'table',
 '#header' =&gt; array(t('Application'), t('Certificate'), t('Uploaded'), t('Expiry Date')),
 'rows' =&gt; array(),
 '#weight' =&gt; 30,
);

foreach($cert_table as $key =&gt; $val) {

$form['certificates']['table']["#rows"]["'r$key'"] = array(
    'c1' =&gt; array(
        'data' =&gt; array('#type' =&gt; 'item', '#markup' =&gt; t('@app_name', array('@app_name' =&gt; $val-&gt;app_name))),
    ),
    'c2' =&gt; array(
        'data' =&gt; array('#type' =&gt; 'item', '#markup' =&gt; t('@cert', array('@cert' =&gt; $val-&gt;cert_name))),
    ),
    'c3' =&gt; array(
        'data' =&gt; array('#type' =&gt; 'item', '#markup' =&gt; t('@uploaded', array('@uploaded' =&gt; date('d-m-Y', $val-&gt;upload_date)))),
    ),
    'c4' =&gt; array(
        'data' =&gt; array('#type' =&gt; 'item', '#markup' =&gt; t('@expiry', array('@expiry' =&gt; date('d-m-Y', strtotime($val-&gt;expiration_date))))),
    ),
);
}
You can add class for the row and add background for this class via the css

$row = array(
  array(
    'data' =&gt; array(
      array( 'data' =&gt; 'cell1'),
      array( 'data' =&gt; 'cell2'),
      array( 'data' =&gt; 'cell3' ),
    ),
    'class' =&gt; array('my-class'),
  )
);

print theme('table', array('rows' =&gt; $row));