PHP翻页的一个类
来源:互联网 发布:大疆算法工程师面试题 编辑:程序博客网 时间:2024/05/24 05:03
/* -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
+------------------------------------------------------------+
| Filename.......: pagenav.php |
| Project........: 大白菜芯 翻 页 |
| Version........: 2.0.0 |
| Last Modified..: 2003-01-16 |
+------------------------------------------------------------+
| Author.........: wapweb(tyler.wu) <java@cu165.com> |
| Homepage.......: http://tjsohu.com |
| Support........: http://tjsohu.com |
+------------------------------------------------------------+
| Copyright ? 2004 tjsohu.com Team. All rights reserved. |
+------------------------------------------------------------+
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
error_reporting(7);
class buildNav{
var $limit;
var $execute,$query;
var $total_result = 0;
var $offset = "offset";
function buildNav($Public,$objClass)
{
$this->Public=$Public;
$this->theClass = $objClass ;
}
function execute($query,$limit){
// global $product;
$GLOBALS[$this->offset] = (!isset($GLOBALS[$this->offset]) OR $GLOBALS[$this->offset]<0) ? 0 : $GLOBALS[$this->offset];
//$this->sql_result = $DB->query($query);
$GLOBALS[$this->offset] = ($GLOBALS[$this->offset]>$this->total_result) ? $this->total_result-10 : $GLOBALS[$this->offset];
if (empty($this->limit)) {
$this->limit = 20;
}else{
$this->limit = $limit;
}
if (isset($this->limit)) {
$query .= " LIMIT " . $GLOBALS[$this->offset] . ", $this->limit";
$this->sql_result = $this->Public->query($query);
$this->num_pages = ceil($this->total_result/$this->limit);
}
if ($GLOBALS[$this->offset]+1 > $this->total_result) {
$GLOBALS[$this->offset] = $this->total_result-1;
}
}
function show_num_pages($frew = "?", $rew = '上一页', $ffwd = '?', $fwd = '下一页', $separator = '') {
$current_pg = $GLOBALS[$this->offset]/$this->limit+1;
if ($current_pg > '5') {
$fgp = ($current_pg-5 > 0) ? $current_pg-5 : 1;
$egp = $current_pg+4;
if ($egp > $this->num_pages) {
$egp = $this->num_pages;
$fgp = ($this->num_pages-9 > 0) ? $this->num_pages-9 : 1;
}
} else {
$fgp = 1;
$egp = ($this->num_pages >= 10) ? 10 : $this->num_pages;
}
if($this->num_pages > 1) {
// searching for http_get_vars
foreach ($GLOBALS[HTTP_GET_VARS] as $_get_name => $_get_value) {
if ($_get_name != $this->offset) {
$this->_get_vars .= "&$_get_name=$_get_value";
}
}
$this->listNext = $GLOBALS[$this->offset] + $this->limit;
$this->listPrev = $GLOBALS[$this->offset] - $this->limit;
// $this->theClass = $objClass;
if (!empty($rew)) { //$separator [$frew] $rew
$return .= ($GLOBALS[$this->offset] > 0) ? "offset=0$this->_get_vars/" $this->theClass title=/"第一页/">$frew offset=$this->listPrev$this->_get_vars/" $this->theClass title=/"上一页/">$rew $separator " : "";
}
// showing pages
if ($this->show_pages_number || !isset($this->show_pages_number)) {
for($this->a = $fgp; $this->a <= $egp; $this->a++) {
$this->theNext = ($this->a-1)*$this->limit;
if ($this->theNext != $GLOBALS[$this->offset]) {
$return .= " offset=$this->theNext$this->_get_vars/" $this->theClass> ";
if ($this->number_type == 'alpha') {
$return .= chr(64 + ($this->a));
} else {
$return .= $this->a;
}
$return .= " ";
} else {
if ($this->number_type == 'alpha') {
$return .= chr(64 + ($this->a));
} else {
$return .= "$this->a";
}
$return .= ($this->a < $this->num_pages) ? " $separator " : "";
}
}
$this->theNext = $GLOBALS[$this->offset] + $this->limit;
if (!empty($fwd)) {
$offset_end = ($this->num_pages-1)*$this->limit; //$separator $fwd [$ffwd]
$return .= ($GLOBALS[$this->offset] + $this->limit < $this->total_result) ? "$separator offset=$this->listNext$this->_get_vars/" $this->theClass title=/"下一页/">$fwd offset=$offset_end$this->_get_vars/" $this->theClass title=/"最后一页/">$ffwd" : "";
}
}
}
return $return;
}
// [Function : Showing the Information for the Offset]
function show_info() {
$return .= "共: ".$this->total_result." , ";
$list_from = ($GLOBALS[$this->offset]+1 > $this->total_result) ? $this->total_result : $GLOBALS[$this->offset]+1;
$list_to = ($GLOBALS[$this->offset]+$this->limit >= $this->total_result) ? $this->total_result : $GLOBALS[$this->offset]+$this->limit;
//$return .= 'Showing Results from ' . $list_from . ' - ' . $list_to . '
';
$return .= "显示: ".$list_from ." - ".$list_to;
return $return;
}
/*因为现在的这个编辑器不能正常解释我西边的代码,我就抓了图来完成真个函数。如果您需要请按照下边的输入就可以了*/
- PHP翻页的一个类
- 一个不错的翻页PHP代码
- PHP连接MSSQLServer数据库和翻页的一个实例
- PHP的翻页功能
- PHP翻页类
- php 翻页区间切割算法(翻页类)
- 一个简单的翻页代码
- 一个翻页的JS代码
- php翻页
- 一个比较好的ASP翻页!
- GitHub上提供的一个翻页控件
- 如何实现一个翻页效果的widget
- 一个简单jsp的翻页控制
- 编写一个键盘翻页的Chrome插件
- 一个asp翻页类,改进版
- php翻页代码
- 用PHP实现翻页
- PHP 实现翻页技巧
- 第十二节--类的自动加载 -- Classes and Objects in PHP5 [12]
- 第十三节--对象串行化 -- Classes and Objects in PHP5 [13]
- 第十四节--命名空间 -- Classes and Objects in PHP5 [14]
- 第十五节--Zend引擎的发展 -- Classes and Objects in PHP5 [15]
- 发第一篇,发现一个问题。
- PHP翻页的一个类
- PHP连接MYSQL的数据库类文件!
- MFC之OpenGL入门程序
- 申请Blog成功,又多了一个交流的地方 :)
- 开通!!!
- 现在已经夜深了!2004年6月23日凌晨3.15分
- 看"Lua让我脸红 "有感
- jsp分页
- 解决jsp中乱码问题