0
我在查看页面中使用分页数据来显示选择页面的链接,但它显示数据库中的所有数据(250个数据)它不是每页30个单独的数据。请帮我我的看法不是通过分页使用独立数据
这是我的模型
function get_item_code($param){
$result = array();
$sql = "select ic.id, ic.item_code, ic.description, maxdt.maxdt, lc.balance,lc.dt ";
$sql .= "from tbl_item_code ic ";
$sql .= "left join (tbl_lines_code lc inner join (select id, max(dt) maxdt from tbl_lines_code where active = 1 group by id) maxdt ";
$sql .= "on lc.id = maxdt.id and lc.dt = maxdt.maxdt) on ic.id = lc.id ";
$sql .= "where ic.active = 1 group by ic.id ";
// echo $sql;
if ($param->limit > 0)
$this->db->limit($param->per_page, $param->limit);
else
$this->db->limit($param->per_page);
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$result = $query->result();
}
return $result;
}
这是我的控制器
public function main(){
$this->load->library('pagination');
$page = $this->uri->segment(3);
$param = new stdClass();
if (!isset($page) || $page == '') {
$page = 1;
}
$param->per_page = 30;
$param->limit = ($page - 1) * $param->per_page;
$paginate_url = site_url('warehouse/main');
$data['total_result'] = $this->m_stock->count_stock();
$config['uri_segment'] = 3;
$config['num_links'] = 4;
$config['base_url'] = $paginate_url;
$config['total_rows'] = $data['total_result'];
$config['per_page'] = $param->per_page;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['item'] = $this->m_stock->get_item_code($param);
$this->load->view('v_all_stocks', $data);
}
,这我认为敌人回声$pagination
<?php
if(isset($pagination) && $pagination != ''){
?>
<div class="search_pagination"><?php echo $pagination; ?></div>
<?php } ?>
,并使用foreach
的数据显示
使用限用这样的偏移。 “SELECT * FROM xyz LIMIT 15,10”; –
你得到了什么? 'get_item_code'? –