All articles(网络文学目录) All Pictures(图片目录) All Softwares(软件目录)

 
用PHP操作MySql数据库(分页)_[PHP教程]

Writer: 归海一刀 Article type: Programming skills(编程技巧) Time: 2014/2/17 7:45:57 Browse times: 321 Comment times: 0

用PHP操作MySql数据库(分页)_[PHP教程]


Head photo

Go homepage
Upload pictures
Write articles

用PHP操作MySql数据库(分页)_[PHP教程] /*
* mysql数据库 分页类
* @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; //图标路径
var img; //图标名称
var img_btn; //图标地址
var page_size; //设置每页显示条数
var num_btn; //设置数字分页的显示个数
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_path.this->img[0]."’ alt=’首页’ border=’0’ align=’absmiddle’/>";
this->img_btn[1] = "img_path.this->img[1]."’ alt=’上一页’ border=’0’ align=’absmiddle’/>";
this->img_btn[2] = "img_path.this->img[2]."’ alt=’下一页’ border=’0’ align=’absmiddle’/>";
this->img_btn[3] = "img_path.this->img[3]."’ alt=’末页’ border=’0’ align=’absmiddle’/>";
}
function set_show_page(){
this->set_img(); //设置翻页图片路径
this->set_url();
this->set_total_records();
if (this->total_recordspage_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;
}
}




There are 0 records,
Comment:
Must be registered users to comment(必须是注册用户才能发表评论)

Disclaimer Privacy Policy About us Site Map
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.