$X = SmartyPaginate::getCurrentIndex(); $Y = SmartyPaginate::getLimit(); $searchSQL = "SELECT * FROM sionapros_news WHERE 1 ORDER BY news_no DESC LIMIT {$X},{$Y}"; $result = $dbcon->execute($searchSQL); foreach ($result as $row) { // collect each record into $_data $data[] = $row; } // now we get the total number of records from the table $rowsSQL = "SELECT COUNT(*) FROM sionapros_news WHERE 1"; $dbcon->query($rowsSQL); #$rowNo = $rows[0]; SmartyPaginate::setTotal($dbcon->getValue()); $dbcon->free(); return $data; } $results = getSearchResults($db); if (sizeof($results) == 0) { $searchMsg = 'NO ARTICLES WERE FOUND'; $smarty->assign('searchMsg', $searchMsg); } else { // assign your db results to the template $smarty->assign('news', $results); // assign {$paginate} var SmartyPaginate::assign($smarty); } $content = $smarty->fetch('./news/tm0.news.display_news.tpl.html'); SmartyPaginate::disconnect(); ?>