php - 如何在分页库codeigniter中编写Segment

标签 php mysql codeigniter

Mysql 段??没有正确理解 在分页中... 这是我的代码:

  $data['query']=   $this->db->select('auto_id,title,image,thumb')
                   ->get('gallery',$config['per_page']=12,$this->uri->segment(3));                    

其中 per_page=12

最佳答案

尝试这样使用->

function records($sort_by = 'rpd_id', $sort_order = 'asc', $offset = 0) {
        $limit = 10;
        $data['results'] = $this->rcbs_Model->get_all_data_from_request($limit, $offset, $sort_by, $sort_order);
        $config = array();
        $config['base_url'] = base_url("rcbs/records/$sort_by/$sort_order");
        $config['total_rows'] = $this->rcbs_Model->count_records();
        $config['per_page'] = $limit;
        $config['uri_segment'] = 5;
        $data['sort_by'] = $sort_by;
        $data['sort_order'] = $sort_order;
        $this->pagination->initialize($config);
        $data['links'] = $this->pagination->create_links();
        $this->load->view('booking_data', $data);
 }

here $sort_by = 'rpd_id' (rpd_id)is the default table column by which data will be sorted.

"get_all_data_from_request" is the function by which you will get all data from your table using select query.

base_url("rcbs/records/$sort_by/$sort_order"); rcbs -Controller name 'records'->function name itselft

$this->rcbs_Model->count_records() count all the records from the table.

关于php - 如何在分页库codeigniter中编写Segment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25932462/

相关文章:

php - PHP session 的 iPhone 问题

php - 如何在wordpress中通过jQuery/Ajax上传图片

mysql - 有更好的方法来执行此查询吗?

php - 使用 Active Record 进行 CodeIgniter 分页

php - 如何在 Symfony 2 中设置表单字段名称?

javascript - 如何从本地主机发送文件到网站

mysql - 在 XAMPP 中创建一个新的 MySQL 用户

mysql - 在sql中获取三个月以上的数据

javascript - Bootstrap 模态体 : Json Refresh After Upload Codeigniter

php - 使用 Codeigniter 的 ActiveRecord 对 SELECT 查询中的列值求和