My first module: db_select question
$header = array(
        array('data' =&gt; 'title',        'field' =&gt; 'title', 'sort' =&gt; 'ASC'),
        array('data' =&gt; 'cal name 1',   'field' =&gt; 'field_order_value'),
        array('data' =&gt; 'Cal name 2',   'field' =&gt; 'field_issue_value'),
    );

// $result = db_query("SQL here");

$rpt_data = array();

    foreach ($results as $key =&gt; $rpt_data1){
        $rpt_data[$key][] = 'Result item';
        $rpt_data[$key][] = $rpt_data1-&gt;product_title;
        $rpt_data[$key][] = $rpt_data1-&gt;stock_value;
    }

    if (count($rpt_data) == 0) {
        $output = t('&lt;div class="no-data"&gt;Record not found.&lt;/div&gt;');
    } else {
        $per_page = 20; // Initialize the pager
        $current_page = pager_default_initialize(count($rpt_data), $per_page);  // Split your list into page sized chunks
        $chunks = array_chunk($rpt_data, $per_page, TRUE);  // Show the appropriate items from the list
        $output = theme('table', array('header' =&gt; $header, 'rows' =&gt; $chunks[$current_page])); // Show the pager
        $output.= theme('pager', array('quantity',count($rpt_data)));
    }