开发工具:
文件大小: 192kb
下载次数: 0
上传时间: 2014-01-08
详细说明:
get = (int)$_GET['startRow']; $this->post = (int)$_POST['pageNums']; $this->pageSize = $pageSize; $this->pageTotal = ceil($total / $pageSize); switch ($_GET['method']){ default: $this->startRow = 1; $this->offset = 0; break; case 'first': $this->first(); break; case 'previous': $this->previous(); break; case 'next': $this->next(); break; case 'last': $this->last(); break; } } /** * 首页方法 * */ public function first(){ $this->startRow = 1; $this->offset = ($this->startRow - 1) * $this->pageSize; } /** * 上一页方法 * */ public function previous(){ $this->startRow = $this->get - 1; if ($this->startRow < 1) { $this->startRow = 1; } $this->offset = ($this->startRow - 1) * $this->pageSize; } /** * 下一页方法 * */ public function next(){ $this->startRow = $this->get + 1; if ($this->startRow > $this->pageTotal) { $this->startRow = $this->pageTotal; } $this->offset = ($this->startRow - 1) * $this->pageSize; } /** * 最后页方法 * */ public function last(){ $this->startRow = $this->pageTotal; $this->offset = ($this->startRow - 1) * $this->pageSize; } /** * 下拉菜单翻页 * * @return Int */ public function numPages(){ if ($this->post) { $pageNums = ""; $this->startRow = $this->post; $this->offset = ($this->post - 1) * $this->pageSize; } for ($i = 1; $i <= $this->pageTotal;$i++){ if ($i != $this->post) { $pageNums .= ""; } } return $pageNums; } /** * 当前是第几页 * * @return Int */ public function noncePage(){ if ($this->post) { return $this->startRow = $this->post; } else { return $this->startRow = $this->startRow; } } } 调用方法: [php] $total = $total->total();//总记录 $pageSize = 15;//每页显示的记录 $pager = new Pager($total,$pageSize); if ($pager->post){$startRow = $pager->noncePage();} $startRow = $pager->startRow; $pager->numPages(); $article->query("SELECT * FROM `categories` as c,`articles` as n WHERE c.id = n.pid ORDER BY n.id DESC LIMIT $pager->offset,$pageSize"); while ($article->fetchArray()) { $article->data['content'] = mb_substr(strip_tags($article->data['content']),0,40,'utf-8'); $articleIndex[] = $article->data; } $article->free(); } else { header("location:?act=login"); } $view->view->assign('startRow',$startRow);//caption $view->view->assign('total',$total);//caption $view->view->assign('pageNums',$pager->numPages());//pageNums $view->view->assign('noncePage',$pager->noncePage());//pageNums $view->view->assign('pageTotal',$pager->pageTotal);//pageTotal 模板页面: [php] ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.