php经典分页类
该软件是以ecshop作为核心的仿制万表网的商场网站源码。万表网模板 2015最新版整体简洁大气,功能实用,是一款时尚典雅的综合类模板!样式精美的商品分类树,层次分明,分类结构一目了然。首页轮播主广告分别对应切换小广告,商品宣传更到位。独家特色增加顶级频道页面、品牌页面,以及仿京东对比功能,提升网站档次,让您的网站更加高端大气!并且全站采用div+css布局,兼容性良好,更注重页面细节,增加多种j
0
class db
{
public $conn,$db,$table,$user,$host,$unm,$pwd;
public $res;
public $char;
public $linkType;
function __construct($linkType=false,$char="gb2312")
{
$this->linkType=$linkType;//设定连接类型
$this->char=$char;//设定连接校对字符
$this->db=DB;
$this->user=USER;
$this->host=HOST;
$this->unm=UNM;
$this->pwd=PWD;
if($this->linkType)
{
$this->conn=mysql_pconnect($this->host,$this->unm,$this->pwd) or die("Database connection failure");
}
else
{
$this->conn=mysql_connect($this->host,$this->unm,$this->pwd) or die("Database connection failure");
}
mysql_select_db($this->db);
mysql_query("set names ".$this->char);
}
function query($sql,$type="true")
{
//$type:默认的操作。 指代select操作
$this->res=mysql_query($sql) or die("SQL Statement error !Please check it again");
$row=$type?mysql_num_rows($this->res):mysql_affected_rows();
$result["res"]=$this->res;
$result["row"]=$row;
return $result;
}
//fetch()方法:获取所有的记录,并写入数组
function fetch($sql)
{
$res=self::query($sql);
while ($rs=mysql_fetch_array($res["res"]))
{
$result[]=$rs;
}
return $result;
}
//获取下一条记录
function fetchNext($filed,$currenID,$table)
{
$sql="select * from $table where $filed>$currenID limit 0,1 ";
return self::fetch($sql);
}
//获取前一条记录
function fetchPre($filed,$currenID,$table)
{
$sql="select * from $table where $filed
return self::fetch($sql);
}
}
class page extends db
{
public $currentPage,$totalRecord,$totalPage,$pageSize;
public $start;
public $flag;
public $sql;
function __construct($sql,$pagesize=5,$flag="page")
{
$this->sql=$sql;
$this->pageSize=$pagesize;
$this->flag=$flag;//设定翻页链接标识符
$row=parent::query($sql);
$this->totalRecord=$row["row"];
$this->totalPage=ceil($this->totalRecord/$this->pageSize);
$page=$_REQUEST[$this->flag];
if($page
{
$this->currentPage=1;
}
else
{
$page>$this->totalPage?$this->currentPage=$this->totalPage:$this->currentPage=$page;
}
$this->start=($this->currentPage-1)*$this->pageSize;
}
//显示分页列表
function show($page=10)
{
$str.='
| ID | UNM |
| =$rs[$i][0]?> | =$rs[$i][1]?> |
| =$page->show()?> | |
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号