$this->分页->create_links();返回空白字符串

发布于 2024-11-09 02:10:56 字数 1239 浏览 0 评论 0原文

<?php
    class Books extends CI_Controller {
    function __construct() {
    parent::__construct();
    $this->load->helper('url');
  }

  function index() {
    // load pagination class
    $this->load->library('pagination');

    $config['base_url'] = base_url().'books/index/';
    $config['total_rows'] = 2;
    $config['per_page'] = '5';
    $config['full_tag_open'] = '<p>';
    $config['full_tag_close'] = '</p>';

    $this->pagination->initialize($config);
    echo $this->pagination->create_links();

  }
    }
?>

create_links();功能似乎不起作用。我没有收到任何错误,但它只返回一个空白字符串。我已经尝试过 http://blip.tv/nettuts/codeigniter- from-scratch-day-7-2690301http://godbit.com /article/pagination-with-code-igniter 教程。

我知道文档说 http://codeigniter.com/user_guide/libraries/pagination.html< /a> 当没有分页显示时,create_links() 函数返回一个空字符串。 但是我该如何解决这个问题呢? 感谢您!

块引用

<?php
    class Books extends CI_Controller {
    function __construct() {
    parent::__construct();
    $this->load->helper('url');
  }

  function index() {
    // load pagination class
    $this->load->library('pagination');

    $config['base_url'] = base_url().'books/index/';
    $config['total_rows'] = 2;
    $config['per_page'] = '5';
    $config['full_tag_open'] = '<p>';
    $config['full_tag_close'] = '</p>';

    $this->pagination->initialize($config);
    echo $this->pagination->create_links();

  }
    }
?>

The create_links(); function seems to not be working. I don't get any errors, but it just returns a blank string. I've tried both http://blip.tv/nettuts/codeigniter-from-scratch-day-7-2690301 and http://godbit.com/article/pagination-with-code-igniter tutorials.

I'm aware the documentation says http://codeigniter.com/user_guide/libraries/pagination.html The create_links() function returns an empty string when there is no pagination to show. but so how do I fix that?
Thanks you!

Blockquote

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丢了幸福的猪 2024-11-16 02:10:56

我想是因为你没有任何分页数据。这是一个有效的示例:

    $this->load->model('books_model', 'books');

    $offset = $this->uri->segment(n);
    $per_page = 5;
    $total = $this->books->total();
    $data['result'] = $this->books->get_all($per_page, $offset);

    $config['base_url'] = base_url().'books/index/';
    $config['total_rows'] = $total;
    $config['per_page'] = $per_page;

    $this->load->vars($data); // !!!
    $this->pagination->initialize($config);

我希望这会对您有所帮助

I think because you don't have any data for pagination. This is a working example:

    $this->load->model('books_model', 'books');

    $offset = $this->uri->segment(n);
    $per_page = 5;
    $total = $this->books->total();
    $data['result'] = $this->books->get_all($per_page, $offset);

    $config['base_url'] = base_url().'books/index/';
    $config['total_rows'] = $total;
    $config['per_page'] = $per_page;

    $this->load->vars($data); // !!!
    $this->pagination->initialize($config);

I hope this will help you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文