English 中文(简体)
$this->pagination->create_links();返回空白字符串
原标题:$this->pagination->create_links(); returning blank string
<?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教程。

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!

区块报价

最佳回答

我认为这是因为您没有任何用于分页的数据。这是一个工作示例:

    $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);

我希望这对你有帮助

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签