你有没有看唠叨的php+mysql分页显示呀
如果是orcal的odbc连接不就改改数据库连接与读取数据的几个相关函数可以了吗????http://community.csdn.net/Expert/topic/3093/3093475.xml?temp=.7862512
如果是orcal的odbc连接不就改改数据库连接与读取数据的几个相关函数可以了吗????http://community.csdn.net/Expert/topic/3093/3093475.xml?temp=.7862512
解决方案 »
- zend studio如何调试一个网站
- mysql查询语句,like'中文字'的问题
- 初级问题。MYSQL写入数据问题
- PHP用多了
- 谁用过PHP在命令行调用,怎么传递参数,有没有例程,我写的都接收不到参数?????
- 本人想找一个主页空间,最好能支持PHP和mysql,价格不要太高。
- 大家谈谈liunx+apache+php+mysql,有多少商业网站是这样架构的?
- 如何将curl_exec()返回的stream转换为string
- 关于mysql和sql server 2000数据库数据同步的问题,来大神给个思路,谢谢
- 新人学习问题1,这段内嵌css为什么不能把图片变成灰色
- 我在网下载的多个BBS,运时都会出一些错误,想问问是不是我的PHP.INI是不是要做什么配置??
- 为何部份jpg图片无法显示??
/*********************************
# Class Name: Ora_page
# Purpose:php&oracle分页类
# Version: 1.0
# Author: piner
**********************************/class Ora_page{
//start class
var $offset; //##:: 偏移量
var $totalNums; //##:: 记录总数
var $where; //##:: 显示条件
var $order; //##:: 显示排序
var $maxLine; //##:: 每页显示行数
var $totalPages; //##:: 总页数
var $currentPage; //##:: 当前页
var $parameter; //##:: 传递的参数
var $db_obj;
/********************************************************
::::::: 功能: 构造函数 ::::::::
::::::: 示例: $SYS=array( ::::::::
::::::: "currentPage" =>$cpage, ::::::::
::::::: "totalPage" =>10 ::::::::
::::::: ); ::::::::
::::::: $obj = Ora_page($SYS); ::::::::
*********************************************************/
function Ora_page($SET_PAGE_VARS){
$this->currentPage = $SET_PAGE_VARS['currentPage'];
$this->maxLine = $SET_PAGE_VARS['maxLine'];
$this-> init();
}
/*******************************************************
::::::::::: 连接 oracle 数据库 ::::::::::::
********************************************************/
function init(){
$this-> db_obj = new DB_ora;
}
/******************************************************
:::::::: 功能: 返回总记录数 ::::::::
*******************************************************/
function totalNums(){
return $this->totalNum;
} /********************************************************
::::::: 功能: 设置显示条件 ::::::
::::::: 示例:where id='$id' order by id desc ::::::
*********************************************************/
function setCondition($where){
$this->where = $where;
// $this->order = $order;
} /********************************************************
:::::::: 功能: 设置传递参数 :::::::
:::::::: 示例: $parameter=array("name"=>$name); :::::::
:::::::: setParameter($parameter); :::::::
*********************************************************/
function setParameter($parameter){
if ( ! is_array($parameter) ) {
print("Invalid:".$parameter." not array");
exit;
}
while(list($key,$val) = each($parameter)) {
$tmp[] = $key."=".$val;
}
$string = implode("&",$tmp);
$this->parameter = $string;
} /********************************************************
:::::::: 功能: 读取数据 :::::::
*********************************************************/
function list_Record($sql) {
global $Tconfig;
$query = "select count(*) as allnum from (".$sql.")";
//$query = "select count(*) as allnum from ".$tb." ".$this->where."";
$this-> db_obj->query($query);
$this-> db_obj->next_record();
$this-> totalNum = $this->db_obj-> Record['ALLNUM'];
$this-> offset = ($this->currentPage-1) * $this->maxLine;
if ($this->totalNum > 0) {
$this-> db_obj->query($sql);
@OCIFetchStatement($this->db_obj->Parse,$record,$this->offset,$this->maxLine,OCI_FETCHSTATEMENT_BY_ROW);
//while($this->db_obj->next_record()){
// $record = $this->db_obj->Record;
//}
return $record;
}
} /********************************************************
:::::::: 功能: 读取当前页,总页数 ::::
*********************************************************/
function curr_Total(){
$this->totalPage = ceil($this->totalNum / $this->maxLine);
$total = $this->totalPage?$this->totalPage:"1";
$ctPage = "第".$this->currentPage."页 共".$total."页 共".$this->totalNum."条记录";
return $ctPage;
} /*********************************************************
:::::::: 功能:读取首页,上页,下页,末页 :::::::::
:::::::: 返回值:数组 :::::::::
:::::::: 示例:mainPage=$obj->main_Page() :::::::::
:::::::: 首页连接->mainPage['first'] :::::::::
:::::::: 上一页连接->mainPage['prev'] :::::::::
:::::::: 下一页连接->mainPage['next'] :::::::::
:::::::: 末页连接->mainPage['last'] :::::::::
**********************************************************/
function main_Page(){
$prev = $this->currentPage - 1;
$next = $this->currentPage + 1;
if ($this->currentPage != 1){
$listPage['first'] = "<a class=link href=".$PHP_SELF."?Cpage=1&".$this->parameter."><font face=webdings>9</font></a>";
}else{
$listPage['first'] = "<font face=webdings>9</font>";
} if ($this->currentPage > 1){
$listPage['prev'] = "<a class=link href=".$PHP_SELF."?Cpage=".$prev."&".$this->parameter."><font face=webdings>7</font></a>";
}else{
$listPage['prev'] = "<font face=webdings>7</font>";
}
if ($this->currentPage < $this->totalPage){
$listPage['next'] = "<a class=link href=".$PHP_SELF."?Cpage=".$next."&".$this->parameter."><font face=webdings>8</font></a>";
}else{
$listPage['next'] = "<font face=webdings>8</font>";
}
if ($this->currentPage < $this->totalPage){
$listPage['last'] = "<a class=link href=".$PHP_SELF."?Cpage=".$this->totalPage."&".$this->parameter."><font face=webdings>:</font></a>";
}else{
$listPage['last'] = "<font face=webdings>:</font>";
}
return $listPage;
} /*********************************************************
::::::::: 功能:读取页数以数字显示:1 2 3..... :::::::::
**********************************************************/
function number_Pages(){
for($i=1;$i<=$this->totalPage;$i++){
if(($i+10 >= $this->currentPage) and ($i-10 <= $this->currentPage))
$numberPage.= ($this->currentPage!=$i)?"<a href=".$PHP_SELF."?Cpage=".$i."&".$this->parameter.">".$i."</a> ":$i." ";
}
return $numberPage;
} // end class
}
?>
$SET_PAGE_VARS['currentPage'] = $Cpage ? $Cpage : 1; //当前页码
$oraPage = new ($SET_PAGE_VARS);$sql = "select id,name from table";
$record = $oraPage-> list_Record($sql);for($i=0; $i<count($record); $i++) //显示记录
{
echo $record[$i]['id'];
}echo $oraPage->curr_Total(); //显示当前页,总页码等
$mainPage = $oraPage->main_Page();
echo $mainPage['first']; //首页
echo $mainPage['prev']; //上一页
echo $mainPage['next']; //下一页
echo $mainPage['last']; //最后一页
function init(){
$this-> db_obj = new DB_ora;
}
这个就能连接数据库了吗?好像还不行吧?
这位大哥,PHPBB是什么东东啊?