解析用PHP操作MySql數(shù)據(jù)庫(kù)_PHP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
<?php
/*
* mysql數(shù)據(jù)庫(kù) 分頁(yè)類(lèi)
* @package pagelist
* @author yytcpt(無(wú)影)
* @version 2008-03-27
* @copyrigth http://www.d5s.cn/
*/
/*
* 分頁(yè)樣式
.page{float: left;font: 11px Arial, Helvetica, sans-serif; padding:6px 0; margin: 0px 10%; margin-top: 10px;}
.page a, .page strong{padding: 2px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.page a:visited{padding: 2px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.page .break{padding: 2px 6px; border: none; background: #fff; text-decoration: none;}
.page strong{padding: 2px 6px; border-color: #999; font-weight: bold; font-size: 13px; vertical-align: top; background: #fff;}
.page a:hover{color: #fff; background: #0063DC; border-color: #036; text-decoration: none;}
.page a:hover div{color: #FFF;cursor: pointer !important;cursor: hand;}
*/
class pagelist{
var page; //分頁(yè)頁(yè)碼
var sql; //分頁(yè)sql
var img_path; //圖標(biāo)路徑
var img; //圖標(biāo)名稱(chēng)
var img_btn; //圖標(biāo)地址
var page_size; //設(shè)置每頁(yè)顯示條數(shù)
var num_btn; //設(shè)置數(shù)字分頁(yè)的顯示個(gè)數(shù)
var total_pages; //一共分多少頁(yè)
var total_records; //一共有多少條記錄
var url;
var table;
var new_sql; //指定的SQL語(yǔ)句
var db;
function __construct(){
global db;
this->db = db;
tmp_page = intval(trim(_GET["page"]));
this->page = empty(tmp_page)?1:tmp_page;
this->set_table();
this->page_size = 20;
this->num_btn = 9;
this->img_path = ’/images/’;
this->img = array("ico_first.gif", "ico_front.gif", "ico_next.gif", "ico_last.gif");
}
function set_table(){
this->table["tablename"] = "";
this->table["id"] = "id";
this->table["orderby"] = this->table["id"];
this->table["descasc"] = "DESC";
this->table["fileds"] = "*";
this->table["where"] = "";
}
function set_img(){
this->img_btn[0] = "<img src=’".this->img_path.this->img[0]."’ alt=’首頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[1] = "<img src=’".this->img_path.this->img[1]."’ alt=’上一頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[2] = "<img src=’".this->img_path.this->img[2]."’ alt=’下一頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[3] = "<img src=’".this->img_path.this->img[3]."’ alt=’末頁(yè)’ border=’0’ align=’absmiddle’/>";
}
function set_show_page(){
this->set_img(); //設(shè)置翻頁(yè)圖片路徑
this->set_url();
this->set_total_records();
if (this->total_records<this->page_size){
this->total_pages = 1;
}else{
this->total_pages = ceil(this->total_records/this->page_size);
}
if (this->page>this->total_pages){
this->page = this->total_pages;
}
}
/*
* mysql數(shù)據(jù)庫(kù) 分頁(yè)類(lèi)
* @package pagelist
* @author yytcpt(無(wú)影)
* @version 2008-03-27
* @copyrigth http://www.d5s.cn/
*/
/*
* 分頁(yè)樣式
.page{float: left;font: 11px Arial, Helvetica, sans-serif; padding:6px 0; margin: 0px 10%; margin-top: 10px;}
.page a, .page strong{padding: 2px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.page a:visited{padding: 2px 6px; border: solid 1px #ddd; background: #fff; text-decoration: none;}
.page .break{padding: 2px 6px; border: none; background: #fff; text-decoration: none;}
.page strong{padding: 2px 6px; border-color: #999; font-weight: bold; font-size: 13px; vertical-align: top; background: #fff;}
.page a:hover{color: #fff; background: #0063DC; border-color: #036; text-decoration: none;}
.page a:hover div{color: #FFF;cursor: pointer !important;cursor: hand;}
*/
class pagelist{
var page; //分頁(yè)頁(yè)碼
var sql; //分頁(yè)sql
var img_path; //圖標(biāo)路徑
var img; //圖標(biāo)名稱(chēng)
var img_btn; //圖標(biāo)地址
var page_size; //設(shè)置每頁(yè)顯示條數(shù)
var num_btn; //設(shè)置數(shù)字分頁(yè)的顯示個(gè)數(shù)
var total_pages; //一共分多少頁(yè)
var total_records; //一共有多少條記錄
var url;
var table;
var new_sql; //指定的SQL語(yǔ)句
var db;
function __construct(){
global db;
this->db = db;
tmp_page = intval(trim(_GET["page"]));
this->page = empty(tmp_page)?1:tmp_page;
this->set_table();
this->page_size = 20;
this->num_btn = 9;
this->img_path = ’/images/’;
this->img = array("ico_first.gif", "ico_front.gif", "ico_next.gif", "ico_last.gif");
}
function set_table(){
this->table["tablename"] = "";
this->table["id"] = "id";
this->table["orderby"] = this->table["id"];
this->table["descasc"] = "DESC";
this->table["fileds"] = "*";
this->table["where"] = "";
}
function set_img(){
this->img_btn[0] = "<img src=’".this->img_path.this->img[0]."’ alt=’首頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[1] = "<img src=’".this->img_path.this->img[1]."’ alt=’上一頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[2] = "<img src=’".this->img_path.this->img[2]."’ alt=’下一頁(yè)’ border=’0’ align=’absmiddle’/>";
this->img_btn[3] = "<img src=’".this->img_path.this->img[3]."’ alt=’末頁(yè)’ border=’0’ align=’absmiddle’/>";
}
function set_show_page(){
this->set_img(); //設(shè)置翻頁(yè)圖片路徑
this->set_url();
this->set_total_records();
if (this->total_records<this->page_size){
this->total_pages = 1;
}else{
this->total_pages = ceil(this->total_records/this->page_size);
}
if (this->page>this->total_pages){
this->page = this->total_pages;
}
}
相關(guān)PHP教程:
- 【PHP Munee】調(diào)整圖片尺寸 + 合并/壓縮CSS JS + 緩存等功能于一身的類(lèi)
- Detector:檢測(cè)用戶(hù)瀏覽器環(huán)境的php類(lèi)
- PHP Thumb:生成圖片縮略圖的類(lèi)
- Hybrid Auth:通過(guò)微博/社交網(wǎng)站和ID來(lái)提供驗(yàn)證功能實(shí)現(xiàn)同步登錄網(wǎng)站功能
- Geocoder:一個(gè)幫助我們建立地理感知應(yīng)用程序的php類(lèi)庫(kù)
- PHPFastCache:強(qiáng)大的開(kāi)源PHP緩存庫(kù)
- PHP Error:解決開(kāi)發(fā)過(guò)程中面臨的PHP錯(cuò)誤信息
- Snoopy:模擬瀏覽器功能的php類(lèi)庫(kù)
- php socket 發(fā)送郵件的庫(kù)
- mysql:分頁(yè)php類(lèi)庫(kù)
- 簡(jiǎn)單實(shí)用的php mysql數(shù)據(jù)庫(kù)連接類(lèi)
- php生成excel文件的類(lèi)庫(kù)
PHP教程Rss訂閱編程教程搜索
PHP教程推薦
- 在動(dòng)態(tài)網(wǎng)頁(yè)技術(shù)PHP5中類(lèi)(CLASS)的新特征
- php調(diào)試?yán)?/a>
- smarty模板引擎之分配數(shù)據(jù)類(lèi)型
- 如何讓PHP支持?jǐn)帱c(diǎn)續(xù)傳文件
- php在window iis的莫名問(wèn)題的測(cè)試方法
- 揭秘PHP+MySQL動(dòng)態(tài)網(wǎng)站開(kāi)發(fā)基礎(chǔ)實(shí)例教程
- PHP使用適合閱讀的格式顯示文件大小的方法
- 解析PHP繪制3D圖形之自定義圖形及矢量圖
- php找出指定范圍內(nèi)回文數(shù)且平方根也是回文數(shù)的方法
- 解讀Mysql中創(chuàng)建用戶(hù)帳戶(hù)的方法
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫(kù)
。