php - 分页链接对我不起作用

标签 php codeigniter

当我在第一页上时,我单击分页链接(2)、链接(3)、链接(4)页面分页链接不起作用。


  <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

    class Pagination extends CI_Controller
    {
    public function __construct() {
    parent:: __construct();

    $this->load->helper("url");
    $this->load->model("Countries_Model");
    $this->load->library("pagination");
    }   
    public function index() {
    $config = array();
    $config["base_url"] = base_url() . "pagination";
    $config["total_rows"] = $this->Countries_Model->record_count();
    $config["per_page"] = 10;
    $config["uri_segment"] = 3;
    $choice = $config["total_rows"] / $config["per_page"];
    $config["num_links"] = round($choice);
    $config['use_page_numbers'] = TRUE;
    $config['page_query_string'] = TRUE;    
    $config['prev_link'] =TRUE; 


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

    $page = ($this->uri->segment(2))? $this->uri->segment(2) : 0;
    $data["results"] = $this->Countries_Model
    ->get_countries($config["per_page"], $page);
    $data["links"] = $this->pagination->create_links();

    $this->load->view("pagination", $data);
    }
    }   ?>

最佳答案

更改此行:

$config["base_url"] = base_url() . "pagination";

$config["base_url"] = base_url("pagination/index");

关于php - 分页链接对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21496569/

相关文章:

php - 无法从 channel 中删除 laravel_database_ 前缀

Fedora 12 上的 phpredis

php - Google App Engine PHP 请求似乎总是转到捕获所有处理程序

arrays - 上传多个文件 userfile[] 数组?

php - session ID : Why does it need to be updated?

php - WordPress $wpdb。插入多条记录

php - 使用 PHP 更新 MySQL 表

php - 图片链接不适用于 codeigniter

php - Mysql Current Timestamp 和 time() 显示不同的值

php - CodeIgniter:将数据从模型传递到 Controller