How to display fetched data in the form of html table?
Try this example to output your data in table format with Pager (ie. table with page. 1,2,3.. )

function custom_table_page_display() {

  $header = array(
    array('data' =&gt; t('Name'), 'field' =&gt; 'id', 'sort' =&gt; 'desc'),
    array('data' =&gt; t('Address'), 'colspan' =&gt; 3),
  );

  $query = db_select('users', 'u');

  $query-&gt;fields('u', array('name','address'));  // select your required fields here

  $table_sort = $query-&gt;extend('TableSort') // Add table sort extender.

                      -&gt;orderByHeader($header); // Add order by headers.

  $pager = $table_sort-&gt;extend('PagerDefault')

                      -&gt;limit(20);  // here you can limit the number of data per page.

  $result = $pager-&gt;execute();

  $rows = array();
  foreach($result as $res) {
    $rows[] = array($res-&gt;id, 
                    $res-&gt; title,);
  }
  // If rows are not empty theme and display the rows.

  $output = '';

  if (!empty($rows)) {

    $output = theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows, 'attributes' =&gt; array('id' =&gt; 'sort-table')));

    $output .= theme('pager');

  }

  else {

    $output .= t("No results found.");

  }

  return $output;

}