当前页数 页导航
总页数1-11 * 输出所有
总页数>11 <7 输出前11条
总页数>11 >总数-6 后11条
总页数>11 其他 前五条,后五条
    /**
     * 选择所有发号信息,联合查询
     * @param array $where
     */
    public function selectAllFaohao($where=array(),$p=1)
    {
        $nums=2;//每页显示数量
        $count=$this->where($where)->count();
        $page['firstpage']=1;
        $page['totalpage']=floor(($count-1)/$nums)+1;
        if(!@is_numeric($p)||@$p<1||$p>$page['totalpage']){$p=1;}
        $page['currentpage']=intval($p);
        $page['totalnum']=$count;
        $page['prevpage']=($p==1)?1:$p-1;
        $page['nextpage']=($p==$page['totalpage'])?$page['totalpage']:$p+1;
        if($page['totalpage']<11)
        {
            $page['navigationstart']=1;
            $page['navigationend']=$page['totalpage'];
        }
        else
        {
            if($page['currentpage']<=6)
            {
                $page['navigationstart']=1;
                $page['navigationend']=11;                
            }
            elseif($page['currentpage']>=$page['totalpage']-6)
            {
                $page['navigationstart']=$page['totalpage']-10;
                $page['navigationend']=$page['totalpage'];                
            }
            else
            {
                $page['navigationstart']=$page['currentpage']-5;
                $page['navigationend']=$page['currentpage']+5;                
            }
        }
        $field="tp_fahao.id ,tp_fahao.game_id ,tp_fahao.type ,tp_fahao.shuoming ,tp_fahao.insert_time ,tp_fahao.user_id ,tp_fahao.common_lb ,tp_gamename.game_name ,tp_gamename.game_gw ,tp_gamename.game_ope ,tp_user.username,tp_user.type as utype";
        $list=$this->where($where)->field($field)->join(' tp_gamename ON tp_fahao.game_id = tp_gamename.id')->join('tp_user ON dbo.tp_user.id=tp_fahao.user_id')->page($p,$nums)->select();
        foreach($list as $key=>$value)
        {
            $list[$key]['insert_time']=date('Y-m-d H:i:s',$value['insert_time']);
        }
        $result['list']=($list==null||$list===false||empty($list))?array():$list;
        $result['page']=$page;
        $result['error']=0;
        return $result;
    }
我的博客:www.shishangguan.net

 我的博客:www.while0.com

posted on 2013-01-09 18:02  money@money  阅读(210)  评论(0编辑  收藏  举报