好吧,我已经搜索并搜索了所有地方,但我仍然找不到解决我的问题的方法。我还是 php 和 codeigniter 的新手,所以也许我已经错过了答案,但无论如何,这就是我想要做的。
这是我的控制器 (c_index.php) - 调用搜索函数并对结果数组执行分页。
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_index extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('m_search');
$this->load->library("pagination");
$this->load->library("table");
}
/** Index Page for this controller */
public function index()
{
if($this->session->userdata('logged_in')){
$this->load->view('v_user');
}
else{
$this->load->view('index');
}
}
public function search()
{
// start of search
$search_term = $this->input->post('word');
$books = $this->m_search->search_books($search_term);
// start of pagination
$config['base_url'] = "http://localhost/test/index.php/c_index/search";
$config['per_page'] = 5;
$config['num_links'] = 7;
$config['total_rows'] = …Run Code Online (Sandbox Code Playgroud)