Theming a custom data table from php code text format with Drupal 7
The format of arguments to theme functions changed in Drupal 7, instead of

$output = theme('table', $header, $rows);


you need to use

$output = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows));


or, using a render array,

$build = array(
  '#theme' =&gt; 'table',
  '#header' =&gt; $header,
  '#rows' =&gt; $rows,
);
$output = drupal_render($build);