Add 'attributes' to an html element
I believe you need to add the data as an array to an associative array with the 'data' key, and the attributes with the attribute name as the key. For instance, your code would look like:

$rows = array();
foreach ($result as $item) {
  $rows[] = array(
    'data' =&gt; array($item-&gt;title, $item-&gt;housestaff_needed),
    'id' =&gt; 'staff-' . $item-&gt;projectID,
  );
}
$theme = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));
return $theme;


I think this will add an id to each &lt;tr&gt;. If you want to add attributes to each individual &lt;td&gt;, you would use a similar structure for $item-&gt;title and $item-&gt;housestaff_needed. That is, it would become:

$rows = array();
foreach ($result as $item) {
  $rows[] = array(
    'data' =&gt; array(
      array(
        'data' =&gt; $item-&gt;title,
        'id' =&gt; 'SOME_ID',
      ),
      array(
        'data' =&gt; $item-&gt;housestaff_needed,
        'id' =&gt; 'SOME_OTHER_ID'
      ),
    ),
    'id' =&gt; 'staff-' . $item-&gt;projectID,
  );
}
$theme = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));
return $theme;


At least, that's how it works in d6, I beleive, so here's hoping it still works in d7.