《mysql class》 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE2 {color: #FF0000}
-->
</style>
</head>

<body>
<p>
  <?php 
class ConnDB{
  var $dbtype;
  var $host;
  var $user;
  var $pwd;
  var $dbname;
  var $conn;
  function ConnDB($dbtype,$host,$user,$pwd,$dbname){
    $this->dbtype=$dbtype;
 $this->host=$host;
 $this->user=$user;
 $this->pwd=$pwd;
 $this->dbname=$dbname;
 
  }
 function GetConnld(){
 $this->conn=mysql_connect($this->host,$this->user,$this->pwd) or die("数据库服务器连接错误".mysql_error());
 mysql_select_db($this->dbname,$this->conn)or die("数据库访问错误".mysql_error());
 mysql_query("set names gb2312");
 return $this->conn;
 
 
 }  
 function CloseConnld(){
   $this->conn->Disconnect();
 }
 
}

class AdminDB{
     function ExecSQL($sqlstr,$conn){
      $sqltype=strtolower(substr(trim($sqlstr),0,6));
   $rs=mysql_query($sqlstr);
   if($sqltype=="select"){
      $array=mysql_fetch_array($rs);
   if(count($array)==0 || $rs==false)
   return false;
   else
   return $array;
  }elseif($sqltype=="update" || $sqltype=="insert" || $sqltype=="delete"){
  if($rs)
         return true;
    else
         return false;
  
  } 
   
   }
  
  }


class SepPage{
       var $rs;
    var $pagesize;
    var $nowpage;
    var $array;
    var $conn;
    var $sqlstr;
    var $total;
    var $pagecount;
    function ShowDate($sqlstr,$conn,$pagesize,$nowpage){
          $arrays=array();
    $array_title=array();
    $array_content=array();
    if(!isset($nowpage) || $nowpage=="" || $nowpage==0)
          $this->nowpage=1;
   else
          $this->nowpage=$nowpage;
   $this->pagesize=$pagesize;
   $this->conn=$conn;
   $this->sqlstr=$sqlstr;
   $this->pagecount=$pagecount;
   $this->total=$total;
   $this->rs=mysql_query($this->sqlstr."limit".$this->pagesize*($this->nowpage-1).",$this->pagesize",$this->conn);
   $this->total=mysql_num_rows($this->rs);
   if($this->total==0){
      return false;
   
   }else{
        if(($this->total % $this->pagesize)==0){
       $this->pagecount=intval($this->total/$this->pagesize);
   }else if($this->total<=$this->pagesize){
         $this->pagecount=1;
   }else{
        $this->pagecount=ceil($this->total/$this->pagesize);
   }  
   while($this->array=mysql_fetch_array($this->rs)){
       array_push($array_title,$this->array[title]);
    array_push($array_content,$this->array[content]);
   }
   array_push($arrays,$array_title,$array_content);
   return $arrays;
   }
   
    }
function ShowPage($contentname,$utits,$anothersearchstr,$class){
         $allrs=mysql_query($this->sqlstr,$this->conn);
         $record=mysql_num_rows($allrs);
   $pagecount=ceil($record/$this->pagesize);
   $str.="共有".$contentname." ".$record." ".$utits." 每页显示 ".$this->pagesize." ".$utits." 第 ".$this->nowpage." 页/共 ".$pagecount." 页";
   $str.="    ";
   $str.="<a herf=".$SERVER['PHP_SELF']."?page=1".$anothersearchstr."class=".$class.">首页</a>";
   $str.=" ";
   if(($this->nowpage-1)<=0){
        $str.="<a href=".$_SERVER['PHP_SELF']."?page=1".$anothersearchstr."class=".$class.">上一页</a>";
     }else{
     $str.="<a href=".$_SERVER['PHP_SELF']."?page=".($this->nowpage-1).$anothersearchstr."class=".$class.">上一页</a>";
     
     
     
   }
   $str.=" ";
   if(($this->nowpage+1)>=$pagecount){
       $str.="<a href=".$_SERVER['PHP_SELF']."?page=".$pagecount.$anothersearchstr."class=".$class.">下一页</a>";
   }else{
   $str.=" ";
     $str.="<a href=".$_SERVER['PHP_SELF']."?page=".($this->nowpage+1).$anothersearchstr."class=".$class.">下一页</a>";
     }
     $str.=" ";
       $str.="<a href=".$_SERVER['PHP_SELF']."?page=".$pagecount.$anothersearchstr."class=".$class.">尾页</a>";
    if(count($this->array)==0 || $this->rs==false){
    return "";
    }else{
    return $str;
    }
}

}


?>

<?php 
$connobj=new ConnDB("mysql","localhost","root","haifeng","haifeng");
$conn=$connobj->GetConnld();
$admindb=new AdminDB();
$seppage=new SepPage();

?>

</p>

<p> </p>
<table width="690" border="0">
  <tr>
    <td>序号</td>
    <td>用户名</td>
    <td>密码</td>
  </tr>
 
 <?php 
 $myrow=$seppage->ShowDate("select * from testhaifeng ",$conn,3,$_GET["page"]);
 if(!$myrow){
     echo"<font color='red'>暂无用户</font>";
  
  
  
 }else{
    for($i=0;$i<count($myrow[0]);$i++){
 ?>
 <tr bgcolor="#00FF99">
 <td><?php  echo $myrow[0][$i];  ?></td>
 <td><?php   echo $myrow[1][$i];  ?></td>
 <td><?php echo $myrow[2][$i];  ?></td>
 <td><?php echo $myrow[3][$i];  ?></td>
 
 
 <?php
 }
 }
?> 
 
 
 
</table>
<p> </p>
</body>
</html>