欧美日韩精品在线,国内精品久久久久久久久,一级毛片恃级毛片直播,清纯唯美亚洲综合欧美色

PHP實(shí)例源代碼:PHP實(shí)現(xiàn)翻頁處理的類_PHP教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:PHP實(shí)例:常用的數(shù)值判斷函數(shù)
以下為引用的內(nèi)容: <HTML> <HEAD> <TITLE>常用的數(shù)值判斷函數(shù)</TITLE> </HEAD> <BODY> <? /


以下為引用的內(nèi)容:
<?php
class Page{

var $CountAll; //共有紀(jì)錄數(shù)
var $CountPage; //每頁顯示記錄數(shù)
var $Link; //顯示 完整的分頁信息
var $ForPage; //上一頁
var $NextPage; //下一頁
var $FirstPage; //第一頁
var $LastPage; //最后一頁
var $CurrPage; //第幾頁
var $PageNum; //共有多少頁
var $Parameter; //參數(shù)
var $LimitNum; //不是統(tǒng)計(jì)全部記錄,而是顯示部分記錄,例如共有100條記錄,但是只統(tǒng)計(jì)顯示前50條

function Page($sql, $num=30){

//初始化,統(tǒng)計(jì)記錄數(shù)
$this->CountPage = $num;
global $mysql;
$sql = base64_decode($sql);
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$row = $mysql->FetchArray($result);
$this->CountAll = $row[0];
}
else{
$this->CountAll = 0;
}
//print "共有 $this->CountAll <br>";
}

function ListPage($sql, $page=0,$sql_all,$other){
//查詢,定義變量,獲取數(shù)據(jù)

global $mysql;
//print "sql sql<br>";
if (isset($this->LimitNum) && $this->CountAll > $this->LimitNum){
$this->CountAll = $this->LimitNum;
}//更新總瀏覽記錄數(shù)

$sql_src = $sql;
//if ($page > 0){
$sql = base64_decode($sql);
$sql_all = base64_decode($sql_all);
$sql_src = $sql;
//}
//echo $sql;
if (($this->CountAll % $this->CountPage) == 0)//統(tǒng)計(jì)共有多少頁
$pagecount = (integer)($this->CountAll/$this->CountPage);
else
$pagecount = (integer)($this->CountAll/$this->CountPage) 1;
$this->ageNum = $pagecount;
if ($page > $this->ageNum)//如果頁碼超過頁碼總數(shù)則設(shè)為最大頁碼
$page = $this->ageNum;
if ($page <= 0)//如果頁碼小于等于零則將頁碼設(shè)置為1
$page = 1;

if ($this->CountAll == 0)
{
$this->CurrPage = 0;
}else{
$this->CurrPage = $page;
}
$first_start = ($page-1)*$this->CountPage;
$sql = $sql." limit ".$first_start.", ".$this->CountPage;
//print "2sql<br>";
$result = $mysql->Query($sql);
if (0 != $mysql->AffectedRows()){
$i = 0;
while($row = $mysql->FetchArray($result)){
$array[$i] = $row;
//print "name:".$array[$i][Name]."<br>";
$i ;
}
}

$sql = base64_encode($sql_src);
$sql_all = base64_encode($sql_all);
if ($pagecount >1){
if($page == 1){
$nextpage = $page 1;
$forpage = 1;
$this->Link = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/next.gif" align="absmiddle"> </button><button onClick="javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_end.gif" align="absmiddle"> </button>";
$this->NextPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/next.gif" align="absmiddle"> </button>";
$this->LastPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_end.gif" align="absmiddle"> </button>";
}
else if(($page > 1)&&($page < $pagecount)) {
$forpage = $page-1;
$nextpage = $page 1;
$this->Link = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_top.gif" align="absmiddle"> </button><button onClick="javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev.gif" align="absmiddle"> </button><button onClick="javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/next.gif" align="absmiddle"> </button><button onClick="javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_end.gif" align="absmiddle"> </button>";
$this->ForPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev.gif" align="absmiddle"> </button>";
$this->NextPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$nextpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/next.gif" align="absmiddle"> </button>";
$this->FirstPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_top.gif" align="absmiddle"> </button>";
$this->LastPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$pagecount".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_end.gif" align="absmiddle"> </button>";
}
else if ($page = $pagecount){
$forpage = $page-1;
$nextpage = 1;
$this->Link = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_top.gif" align="absmiddle"> </button><button onClick="javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev.gif" align="absmiddle"> </button>";
$this->FirstPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=1".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev_top.gif" align="absmiddle"> </button>";
$this->ForPage = "<button onClick="javascript:location.href='?query_sql=$sql&query_page=$forpage".$this->Parameter."&sql_all=".$sql_all."".$other."'" class="button_a" style="width:30;height:22";><img src="images/prev.gif" align="absmiddle"> </button>";
}
}
else{
$this->Link = ' ';
}

return $array;//$array;

}

}
/***************
使用例子

include("class.config.php");
include("class.mysql.php");
include("class.page.php");
global $mysql;
$config = new Config;
$mysql = new TDatabase($config);

$query_all = "select count(*) from user";
$page_object = new Page($query_all,20);
//new Page('統(tǒng)計(jì)記錄個(gè)數(shù)語句',每頁記錄個(gè)數(shù))
if(empty($query_page))
$query_sql = "select * from user";
//注意這里的變量名必須為 $query_sql $query_page ,因?yàn)橄乱豁摰倪B接參數(shù)默認(rèn)為 query_sql query_page

$list = $page_object->ListPage($query_sql,$query_page);
//ListPage('沒有l(wèi)imit的前一部分,系統(tǒng)自動(dòng)根據(jù)補(bǔ)齊',察看的頁數(shù))
$page_object->Parameter = '&action=view';
//這是傳送的Url 所帶的其它參數(shù),如果有就修改變量 Parameter ,系統(tǒng)自動(dòng)將她補(bǔ)在后面
//顯示數(shù)據(jù)
for ($i=0;$i< $page_object->CountPage;$i )
print $list[$i][ID]."->".$list[$i][UserName]."<br>";
//返回的數(shù)據(jù)為二維哈西(關(guān)聯(lián))數(shù)組,一維為紀(jì)錄的標(biāo)識(shí)ID號(hào),二維為哈西(關(guān)聯(lián))數(shù)組,取值標(biāo)識(shí)建議采取用數(shù)據(jù)庫中字段名的方法,例如list[0][UserName]。

//顯示其他相關(guān)數(shù)據(jù)
echo $page_object->CountAll;//紀(jì)錄總數(shù)
echo $page_object->CountPage;//每頁顯示數(shù)據(jù)個(gè)數(shù)
echo $page_object->Link;//顯示完整的分頁信息
echo $page_object->FirstPage;//第一頁
echo $page_object->NextPage;//下一頁
echo $page_object->ForPage;//上一頁
echo $page_object->LastPage;//最后一頁
echo $page_object->CurrPage;//第幾頁
echo $page_object->PageNum;//共有多少頁
$mysql->DatabaseClose();
****************/

?>


分享:PHP實(shí)例:實(shí)現(xiàn)文件上傳的程序源碼
如何實(shí)現(xiàn)文件上傳? 以下為引用的內(nèi)容: <HTML> <HEAD> <TITLE>文件上傳界面</TITLE> </HEAD> <B

來源:模板無憂//所屬分類:PHP教程/更新時(shí)間:2008-08-22
相關(guān)PHP教程