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'? –