";
while($row=mysql_fetch_array($result))
{
if($row["up_oracle"]==2)
{
$error="存在重复";
}
if($row["up_oracle"]==3)
{
$error="插入没成功";
}
echo "";
}
mysql_free_result($result);
}
function get_page_sum($sql)
{
$row_num=mysql_num_rows(mysql_query($sql));
$page_sum=ceil($row_num/$this->page_num);
$this->page_sum=$page_sum;
}
function get_page_head($sql)
{
$row_num=mysql_num_rows(mysql_query($sql));
if($row_num==0)
{
$head="
没有您要查找的记录
"; echo "

其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
php与mysql完成的分页类(自家用)

作者:未知 来源:月光软件站 加入时间:2005-6-5 月光软件站

这个分页是上次发的java分页的基础,我是在php的基础上,完成的其他的分页,思想基本一样,把此函数改造后,才能适应真正的使用,样式的控制在do-while这个函数上
class page
{
var $user="root";
var $passwd="";
var $host="127.0.0.1";
var $port="3306";
var $dbname="soohuo";
//var $server=$this->host.":".$this->port;
var $page_num=30;//每页显示的条数
var $con;//库连接成功句柄
var $result;//查询成功句柄
var $page_sum;//总共的页数
function page($sql,$url)
{
$this->db_connect();
$this->get_page_sum($sql);
if(!isset($_GET["page"])||$_GET["page"]==0)
$page=1;
else
$page=$_GET["page"];
$url=$url."?page=";
$foot="
";
if($page>1)
$foot=$foot."上一页  ";
$foot=$foot."当前是第$page 页";
if($this->page_sum>1&&$page<$this->page_sum)
$foot=$foot."  下一页";
if($this->page_sum>1)
{
$foot=$foot." 跳到第 页";
}
$foot.="
";
$start=($page-1)*$this->page_num;
$end=$this->page_num;
$sql1=$sql." limit $start,$end";
$this->db_query($sql1);
$this->get_page_head($sql);//page head
$this->db_while();//page body
echo $foot;//page end
}
function db_while()
{
$result=$this->result;
echo "
ID号标题错误原因
".$row["data_id"]."".$row
["title"]."
".$error."
$head
";
exit();
}
$page_sum=ceil($row_num/$this->page_num);
$head="
共有记录 $row_num 条 共 $page_sum 页
";
echo ""; $this->page_sum=$page_sum;
}
function db_connect()
{
$server=$this->host.":".$this->port;
$con=mysql_connect($server,$this->user,$this->passwd);
if(!$con)
{
echo "database is connect error!".mysql_error()."
"; exit();
}
$select=mysql_select_db($this->dbname);
if(!$select)
{
echo "select is not database error!".mysql_error()."
"; exit();
}
$this->con=$con;
}
function db_query($sql)
{
if($sql=="")
{
echo "query is not null
";
exit();
}
$result=mysql_query($sql,$this->con);
if(!$result)
{
echo "\$sql error
";
echo "\$sql is $sql
";
exit();
}
$this->result=$result;
}
}
?>


$head

相关文章

相关软件