0

我不知道为什么它不起作用。我关注了很多文章,但似乎我的代码完全错误,我需要删除所有东西。<<1,2,3>>这个标志来了,但是当我点击任何东西时,只有 url chng 什么也没发生别的。

这是我的控制器

function view($offset=0){
            $limit=5;
            //$this->uri->segment(3);
            $this->load->model('emp_expenses_model');
            //$result['contents']=$this->emp_expenses_model->getRows($limit,$offset);
            $result['countRows']=$this->emp_expenses_model->countRows();
            $this->load->library('pagination');
            $this->load->library('table');
            $config=array(
                            'base_url' =>site_url ('/view_expenses/view?'),
                            'total_rows' => $result['countRows'],
                            'per_page' => $limit,
                            'uri_segment' => 3,
                            //'num_links' => 200,
             );  
             //var_dump($config); 
            $this->db->limit('5');
            $this->pagination->initialize($config);
            $this->load->model('emp_expenses_model');
            $this->data['view_expenses'] = $this->emp_expenses_model->get_all();
            //$this->data['pagination'] = $this->pagination->create_links();
            //var_dump($this->data['pagination']);die("jk");
            $this->data['title'] = 'Payroll System';
            $this->data['message'] = $this->session->flashdata('message');
                $this->load->library('pagination');
            $this->load->view('view_expenses', $this->data);
            /*$this->load->view('add_list', $this->data);*/

        }       

这是我的模型

<?php
class Emp_expenses_model extends CI_Model
{
    function emp_expenses_model()
    {
        parent::__construct();
    }
    function get_all()
    {
        $this->db->select('expenses_id,id,dropdown,modeofpayment,amount');
        $query=$this->db->get('emp_expenses');

        return $query->result_array();
    }
    function get_record($list_id)
    {
        $this->db->select('expenses_id,id, dropdown, modeofpayment, amount');
        $this->db->where('id',$list_id);
        $query=$this->db->get('emp_expenses');

        return $query->result_array();

    }
    function insert_list($data)
    {
        $this->db->insert('emp_expenses', $data);
        $id = $this->db->insert_id();
        return (isset($id)) ? $id : FALSE;

    }

    public function update_list($list_id, $data)
    {
        $this->db->where('id', $list_id);
        $this->db->update('emp_expenses', $data);
    }

    public function del_list($list_id)
    {
        $this->db->where('id', $list_id);
        $this->db->delete('emp_expenses');
    }
    function getRows($limit,$offset)
    {
    $query=$this->db->select('expenses_id,id,dropdown,modeofpayment,amount')
           ->from('emp_expenses')
           ->limit($limit,$offset);
    $result=$query->get()->result_array();
    return $result;
    //var_dump($result);
    }
    function countRows()
    {
    //$query="select count(*) as count from emp_expenses";
    $result = $this->db->count_all_results('emp_expenses');
    //$result=$this->db->query($query);
    return $result;
    //var_dump('countRows');
}

并且在我正在写的表格内 *

<?php echo $this->pagination->create_links()?>
4

2 回答 2

0

试试这个,希望它有帮助:
编辑:

function view($offset=0){
    $limit=5;
    $this->load->model('emp_expenses_model');
    $countRows=$this->emp_expenses_model->countRows();
    $this->load->library('pagination');
    $this->load->library('table');
    $config=array(
                    'base_url' =>base_url('/index.php/view_expenses/view/'.$this->uri->segment(3)),
                    'total_rows' => $countRows,
                    'per_page' => $limit,
                    'uri_segment' => 3,
     );  
    $this->pagination->initialize($config);
    $this->data['view_expenses'] = $this->emp_expenses_model->getRows($limit,$this->uri->segment(3));
    $this->data['title'] = 'Payroll System';
    $this->data['message'] = $this->session->flashdata('message');
    $this->load->view('view_expenses', $this->data);
}
于 2013-08-13T08:38:59.637 回答
0

控制器中的功能

function users(){
            if ($this->ion_auth->is_admin() && $this->ion_auth->logged_in()){   
                    $this->load->model('reciever');
                    $this->load->library('uri');
                    $this->load->library('pagination');
                    $config['base_url'] = base_url(). 'users_ci/users';
                    $config['total_rows'] = $this->reciever->getRows();
                    $config['per_page'] = 4;
                    $config['num_links']=2;
                    $config['users']= $this->reciever->getUsers(4,$this->uri->segment(3));
                    $this->pagination->initialize($config);
                    $config['pages'] = $this->pagination->create_links();
                    $this->load->view('users',$config);
             }else{
                 $this->load->view('login_form');
             }
      }

这是为了视图

   <?php echo $pages; ?>

您必须准确地查询您的数据库,其中包含您希望在页面中看到的数量

于 2013-10-21T12:15:49.787 回答