How do you make sortable tables with a pager with data from a custom table?
You use the so called extenders.  In your case, the code would be similar to the following one.

$header = array(
  array('data' =&gt; t('Order id'), 'field' =&gt; 'order_id'),
  // ...
  array('data' =&gt; t('Transaction time'), 'field' =&gt; 'payment_time', 'sort' =&gt; 'desc'),
);

// Initialize $query with db_select().
$query = db_select('your table name');

// Add the fields you need to query.
// ... 

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

// Add the pager.
$query = $query-&gt;extend('PagerDefault')-&gt;limit(25);
$result = $query-&gt;execute();


See HowTo: Convert a module to DBTNG, Dynamic queries: Table sorting and Extenders.