【问题标题】:My pagination link is not working我的分页链接不起作用
【发布时间】:2014-04-10 01:08:51
【问题描述】:

我是 CodeIgniter 框架的新手,我正在尝试使用分页类。所以我遇到了一些麻烦。

情况 数据显示没问题。但是转到表格其他页面的链接不起作用。当我单击“1,2,3”按钮时,它不会用于其他数据。它仍然在同一个地方。

问题 我的代码的主要问题是什么?

我的控制器:

public function view_all_staff() {
        if(!$this->user_auth_model->logged_in()) {
            redirect('user/login');
        } else {

            $config = array();
            $limit                = 1;
            $this->load->library('pagination');
            $this->load->library('table');
            $uri_segment          = 4;
            $offset               = $this->uri->segment($uri_segment);
            $config['base_url']   = base_url() . 'admin/view_all_staff';
            $admin = "Admin";
            $query                = $this->db->query("SELECT * FROM admin where login_type = '".$admin."'");
            $config['total_rows'] = $query->num_rows();

            $config['per_page'] = $limit;

            $config['uri_segment']   = $uri_segment;
            $config['cur_tag_open']  = '<li class="active"><a href="' . base_url() . $this->uri->uri_string() . '">';
            $config['cur_tag_close'] = '</a></li>';

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

            $this->pagination->initialize($config);
            $sel = $this->db->select('*');
            $sel = $this->db->where('login_type =', 'Admin');

            $records = $this->db->get('admin', $config['per_page'], $this->uri->segment(4));
            foreach ($records->result() as $item) {
                $q[] = $item;
            }
            $data['records']          = $q;
            $data['total_rows']       = $query->num_rows();
            $data['per_page']          = $limit;
            $data['uri_segment']      = $uri_segment;
            $data['create_staff_suc'] = $this->session->flashdata('create_staff_suc');

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

我的观点:

<tr><td colspan="5" style="margin-top: inherit; text-align: right;"> <?php echo $this->pagination->create_links(); ?></td></tr>
                                    <?php } else { ?>
                                    <tr><td colspan="5" style="margin-top: inherit; text-align: center;"> <?php echo "No Records Found"; ?></td></tr>
                                    <?php } ?>

希望有人能告诉我是什么问题。

【问题讨论】:

  • 您并没有真正提供任何功能代码。您提供的只是变量定义和调用。没有办法回答这个问题。你甚至没有指定编程语言。
  • 哦,对不起。我是这个网站的新手。我会尽量让你们更清楚。

标签: php codeigniter pagination


【解决方案1】:

我认为您的 $uri_segement 需要为 3,而不是 4,基于您的 base_url 仅使用 2 个段 (admin/view_all_staff)。

【讨论】:

    猜你喜欢
    • 2014-12-09
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 2014-02-03
    • 2021-01-11
    相关资源
    最近更新 更多