亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問板塊 發(fā)新帖
查看: 1959 | 回復(fù): 0
打印 上一主題 下一主題

php新手之mysql分頁(yè)P(yáng)ageQuery類 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2004-12-27 09:48 |只看該作者 |倒序?yàn)g覽
  提供完全可以使用的類,使用時(shí)請(qǐng)初始化各函數(shù)!
dbClass();
        $this->maxLine = $pageLine;
      }
      
      // 記錄總數(shù)
    function getTotal(){
        return $this->Total;
    }
      
      // 顯示總頁(yè)數(shù)
    function getTotalPages() {
        return $this->TPages;
    }
    //顯示當(dāng)前所在頁(yè)數(shù)
    function getCurrenPages() {         
        return $this->CPages;
    }
   
    function myQuery($sql, $flag=1){
            GLOBAL $offset;
            $this->Query = $sql;
        
        // 獲取文件名
        //$this->FilePath = $GLOBALS["REQUEST_URI"];
            $this->FilePath = $GLOBALS["SCRIPT_NAME"];
            
            // 獲取查詢條件
            $this->QueryString = $GLOBALS["QUERY_STRING"];            
            //echo $this->QueryString . "
";            
            
            // 截取 " from " 以后的 query 語(yǔ)句
            $this->QueryPart = trim(strstr($sql, " from "));
            
            // 計(jì)算偏移量
            if (!isset($offset)) $this->Offset = 0;
            else $this->Offset = (int)$offset;
            
            
        
        
        // 計(jì)算總的記錄條數(shù)
        $SQL = "SELECT Count(*) AS total " . $this->QueryPart;
        $this->result = $this->executeQuery($SQL);
            $this->Total = mysql_result($this->result,0);
            
            // 設(shè)置當(dāng)前頁(yè)數(shù)和總頁(yè)數(shù)
        $this->TPages = (double)Ceil((double)$this->Total/$this->maxLine);
        $this->CPages = (double)Floor((double)$this->Offset/$this->maxLine+1);
        
        
        // 根據(jù)條件判斷,取出所需記錄
        if ($this->Total > 0) {
            //flag等于1表示要分頁(yè),否則不分頁(yè)
            if($flag==1)
                $SQL = $this->Query . " LIMIT " . $this->Offset . " , " . $this->maxLine;
            else
                $SQL = $this->Query;            
            echo $SQL . "
";
            $this->$result = $this->executeQuery($SQL);
        }
        return $this->result;
    }
   
    //**********顯示翻頁(yè)提示欄*************  
    // 顯示首頁(yè)、下頁(yè)、上頁(yè)、尾頁(yè)
    function PageLegend() {        
        $str = "";
        $i = 0;
        $first = 0;
        $next = 0;
        $prev = 0;
        $last = 0;
   
            $next = $this->Offset + $this->maxLine;
            $prev = $this->Offset - $this->maxLine;
            $last = ($this->TPages - 1) * $this->maxLine;
            
            GLOBAL $offset;
            if (!isset($offset)) $this->QueryString .= "&offset=";
            else{
                $this->QueryString = substr($this->QueryString,0,strrpos($this->QueryString,'&')) . "&offset=";
            }
            
            if($this->Offset >= $this->maxLine)
            $str .=  " FilePath . "?" . $this->QueryString . $first . ">首頁(yè) ";
            else $str .= " 首頁(yè) ";
        
        if($prev >= 0)
            $str .=  " FilePath . "?" . $this->QueryString . $prev . ">前頁(yè) ";
        else $str .= " 前頁(yè) ";
        
        if($next Total)
            $str .=  " FilePath . "?" . $this->QueryString . $next . ">后頁(yè) ";
        else $str .= " 后頁(yè) ";
        
        if($this->TPages != 0 && $this->CPages TPages)
            $str .=  " FilePath . "?" . $this->QueryString . $last . ">尾頁(yè)";
        else $str .= " 尾頁(yè) ";
        $str .= " 頁(yè)次:" . $this->getCurrenPages() . "/" . $this->getTotalPages() . "頁(yè) ";
        $str .= $this->maxLine . "條/頁(yè) " . "共" . $this->Total . "條";
            return $str;
    }
}
?>


本文來(lái)自ChinaUnix博客,如果查看原文請(qǐng)點(diǎn):http://blog.chinaunix.net/u/3052/showart_8770.html
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP