0

我的问题是,当我按下分页链接时,URL CHANGE 和段数组也是如此,首先我从这个 URL 开始:

site/argument/argument

当我按下分页链接时,URL 变成:

site/method/startIndex.

有没有办法在不使用 URL 查询索引的情况下使用分页?

编辑:

这是我从 URL 接收参数的控制器方法:

function index ($par1, $par2 = null, $par3 = null)
{       
    $data['records'] = $this->site_model->getRecords($par1, $par2, $par3);

    $this->load->view('main', $data);
}

这是我进行数据库查询的模型方法:

function getRecords($par1, $par2 = null, $par3 = null )
{
    if (!isset($par2) && !isset($par3)) {
        $where = "lvlOne = '".$par1."'";

    } elseif(isset($par2) && !isset($par3)) {
        $where = "lvlOne = '".$par1."' AND lvlTwo = '".$par2."'";

    } elseif(isset($par2) && isset($par3)) {
        $where = "lvlOne = '".$par1."' AND lvlTwo = '".$par2."' AND lvlThree = '".$par3."'";
    }

    $this->db->from('mph_products');
    $this->db->where($where);
    $query = $this->db->get();


    return $query->result();
}

我怎样才能对这个结果进行分页?因为我与分页库 URL 有冲突

编辑:

我找到了一种方法来做我想做的事。分页库有一个配置选项,您可以在其中放置分页锚的后缀,您可以将参数传递给它。

$config['suffix'] = "$arg1/$arg2/$arg3";

:D

4

2 回答 2

0

这个库codeigniter分页+引导设计

<?php

class Paginacao
{
public $CI;

function __construct() {
    $this->CI = &get_instance();
    $this->CI->load->library('pagination');

}

function criar($total_rows,$base_url,$per_page=15,$num_links=5)
{
    $paginacao['total_rows'] = $total_rows;

        $paginacao['base_url'] = site_url($base_url);
        $paginacao['per_page'] = $per_page;
        $paginacao['num_links'] = $num_links;

        $paginacao['full_tag_open'] = '<br /><div class="pagination pagination-centered"><ul>';
        $paginacao['full_tag_close'] = '</ul></div>';

        $paginacao['first_link'] = 'Primeira';
        $paginacao['first_tag_open'] = '<li>';
        $paginacao['first_tag_close'] = '<li>';

        $paginacao['last_link'] = 'Ultima';
        $paginacao['last_tag_open'] = '<li>';
        $paginacao['last_tag_close'] = '</li>';

        $paginacao['next_link'] = 'Próximo';
        $paginacao['next_tag_open'] = '<li>';
        $paginacao['next_tag_close'] = '</li>';

        $paginacao['prev_link'] = 'Anterior';
        $paginacao['prev_tag_open'] = '<li>';
        $paginacao['prev_tag_close'] = '</li>';        

        $paginacao['cur_tag_open'] = '<li class="active"><a href="#">';
        $paginacao['cur_tag_close'] = '</a></li>';

        $paginacao['num_tag_open'] = '<li>';
        $paginacao['num_tag_close'] = '</li>';

        $this->CI->pagination->initialize($paginacao);
        $html = $this->CI->pagination->create_links();

    return $html;
}

}

于 2013-08-13T18:07:49.950 回答
0

据我了解,您不想在 url 中看到页码,但 CI Pagination 类总是在链接中添加数字。有关更多详细信息,请参阅分页类

您还可以将jquery数据表用于客户端或服务器分页。

于 2013-08-13T18:03:50.793 回答