php 數組分頁

public function supplys($condition,$page,$count) { $ids = $this->getIds(); $qiu = $this->db->select("col.id AS coleid, a.title,a.addtime, c.name AS conpanyname ") ->from('hh_collection AS col') //求購
            ->join('hh_asktobuy AS a','col.joinID = a.id','right') // 收藏
            ->join('hh_company AS c','c.id = a.companyid','left') // 關聯公司
            ->where("a.id in($ids) AND $condition") ->get() ->result_array(); $gong = $this->db->select("col.id AS coleid, a.title,a.addtime, c.name AS conpanyname ") ->from('hh_collection AS col') //供應
            ->join('hh_supply AS a','col.joinID = a.id','right') // 收藏
            ->join('hh_company AS c','c.id = a.companyid','left') // 關聯公司
            ->where("a.id in($ids) AND $condition") ->get() ->result_array(); $list = array_merge($qiu, $gong); if($count){ return count($list); } // 數組分頁
        $count = count($list);//總條數
        $start=($page-1)*5;//偏移量,當前頁-1乘以每頁顯示條數
        $list = array_slice($list,$start,5); foreach ($list as $k => $v){ $list[$k]['state'] = 0; } return $list; p($list); }

 

 

php數組分頁主要就是 array_slice函數的使用php

    $count = count($list);//總條數
        $start=($page-1)*5;//偏移量,當前頁-1乘以每頁顯示條數
        $list = array_slice($list,$start,5);
相關文章
相關標籤/搜索