db_select doesnt work with me i've problem using db_select it return strange object instead of the result 
here is the code

function _table_subscrib(){
  $result = db_select('user_company','uc')
-&gt;fields('uc',array('user_company_uid','user_company_nid','user_company_sub_number','user_co    mpany_date'))
          -&gt;extend('TableSort')
         -&gt;extend('PagerDefault') 
         -&gt;limit(50)
         -&gt;execute();   

$header = array('User Name','Company Name','Subscribtion Number','Date');

$rows = array();
while($data = $result-&gt;fetchAssoc());
{
    $rows[] = array(
        $data['user_company_uid'],
        $data['user_company_nid'],
        $data['user_company_sub_number'],
        $data['user_company_date']
    );
    drupal_set_message("ssdsd");
}

$output = theme_table(
            array(
                "header" =&gt; $header,
                "rows" =&gt; $rows,
                "attributes" =&gt; array(),
                "sticky" =&gt; true, 
                "caption" =&gt; "",
                "colgroups" =&gt; array(),
                "empty" =&gt; t("Table has no row!") // The message to be displayed if table is empty
                )
            ).theme("pager");

return $output;


}

here is the object returned too

DatabaseStatementBase Object ( [dbh] => DatabaseConnection_mysql Object ( [shutdownRegistered:protected] => [target:protected] => default [key:protected] => default [logger:protected] => [transactionLayers:protected] => Array ( ) [driverClasses:protected] => Array ( [SelectQuery] drupal......

thanks
You set incorrect semicolon at the end, remove it: while($data = $result-&gt;fetchAssoc());

And next manner looks more clear, instead using while:

foreach($result as $data) {
    $rows[] = array(
        $data-&gt;user_company_uid,
        $data-&gt;user_company_nid,
        $data-&gt;user_company_sub_number,
        $data-&gt;user_company_date,
    );
}