Use return data from one function in another and pass it to Smarty template

What I’m trying to do is to have one datatable probably as a template and passing different datas on different pages.

Example functions.php

function force() {
    global $DBconn;
    $q =  "SELECT * FROM table";
    $res = $DBconn->query($q);                              
    
    return $this->result;
}

function force_1() {
    global $DBconn;
    $q =  "SELECT * FROM table_1";
    $res = $DBconn->query($q);                              
    return $this->result;
}

function table() {

      echo '
         <table class="sortable">
            <thead>
            <tr>
                <th>
                    Title
                </th>
            </tr>
            </thead>
            <tbody>';
                foreach ($this->result as $key) {
               echo ' <tr>
                    <td>
                        $key->name
                    </td>
                </tr>';
                }
            echo '</tbody>
        </table>';
    }
  return true;
}

Then in the page.php

$table = table();
$smarty->assign("table", $table);

and page.tpl

<div> {$table} </div>

Currently nothing showed on page, not even an error or something. So:

  1. Is this the way that should be done? With using the returned result in either function and then pass it to the smarty template?