解析用PHP操作MySql數(shù)據(jù)庫_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
<?php
/*
* mysql數(shù)據(jù)庫 分頁類
* @package pagelist
* @author yytcpt(無影)
* @version 2008-03-27
* @copyrigth http://www.d5s.cn/
*/
/*
* 分頁樣式
.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; //分頁頁碼
var sql; //分頁sql
var img_path; //圖標(biāo)路徑
var img; //圖標(biāo)名稱
var img_btn; //圖標(biāo)地址
var page_size; //設(shè)置每頁顯示條數(shù)
var num_btn; //設(shè)置數(shù)字分頁的顯示個(gè)數(shù)
var total_pages; //一共分多少頁
var total_records; //一共有多少條記錄
var url;
var table;
var new_sql; //指定的SQL語句
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=’首頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[1] = "<img src=’".this->img_path.this->img[1]."’ alt=’上一頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[2] = "<img src=’".this->img_path.this->img[2]."’ alt=’下一頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[3] = "<img src=’".this->img_path.this->img[3]."’ alt=’末頁’ border=’0’ align=’absmiddle’/>";
}
function set_show_page(){
this->set_img(); //設(shè)置翻頁圖片路徑
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ù)庫 分頁類
* @package pagelist
* @author yytcpt(無影)
* @version 2008-03-27
* @copyrigth http://www.d5s.cn/
*/
/*
* 分頁樣式
.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; //分頁頁碼
var sql; //分頁sql
var img_path; //圖標(biāo)路徑
var img; //圖標(biāo)名稱
var img_btn; //圖標(biāo)地址
var page_size; //設(shè)置每頁顯示條數(shù)
var num_btn; //設(shè)置數(shù)字分頁的顯示個(gè)數(shù)
var total_pages; //一共分多少頁
var total_records; //一共有多少條記錄
var url;
var table;
var new_sql; //指定的SQL語句
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=’首頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[1] = "<img src=’".this->img_path.this->img[1]."’ alt=’上一頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[2] = "<img src=’".this->img_path.this->img[2]."’ alt=’下一頁’ border=’0’ align=’absmiddle’/>";
this->img_btn[3] = "<img src=’".this->img_path.this->img[3]."’ alt=’末頁’ border=’0’ align=’absmiddle’/>";
}
function set_show_page(){
this->set_img(); //設(shè)置翻頁圖片路徑
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 + 緩存等功能于一身的類
- Detector:檢測用戶瀏覽器環(huán)境的php類
- PHP Thumb:生成圖片縮略圖的類
- Hybrid Auth:通過微博/社交網(wǎng)站和ID來提供驗(yàn)證功能實(shí)現(xiàn)同步登錄網(wǎng)站功能
- Geocoder:一個(gè)幫助我們建立地理感知應(yīng)用程序的php類庫
- PHPFastCache:強(qiáng)大的開源PHP緩存庫
- PHP Error:解決開發(fā)過程中面臨的PHP錯(cuò)誤信息
- Snoopy:模擬瀏覽器功能的php類庫
- php socket 發(fā)送郵件的庫
- mysql:分頁php類庫
- 簡單實(shí)用的php mysql數(shù)據(jù)庫連接類
- php生成excel文件的類庫
- 相關(guān)鏈接:
- 教程說明:
PHP教程-解析用PHP操作MySql數(shù)據(jù)庫
。