宝马娱乐在线城-宝马娱乐在线

来自 互联网络 2019-10-01 17:10 的文章
当前位置: 宝马娱乐在线城 > 互联网络 > 正文

php分页类宝马娱乐在线

pg_close($pgsql_conn);
}
?>

<?php
class conn{
宝马娱乐在线,function __construct(){
  require("config.php");
  $conn = @mysql_connect($host,$root,$pass);
  @mysql_select_db($db);
  if(!$conn){
   echo "无法连接".mysql_errno() . ":" . mysql_error() ;
   exit;
  }
}
function query($sql){
  $result = @mysql_query($sql);
  if (!$result) {
   echo mysql_errno().":".mysql_error();
   exit;
  }
  return $result;
}
function next($result){
  return  @mysql_fetch_array($result);
}
function count_row($result){
  $row = @mysql_num_rows($result);
  return $row;
}
function close($result){
  @mysql_free_result($result);
  @mysql_close();
}
}
class fenye extends conn{
public $sql;
public $page;
public $countpage;
public $pagesize;
public $result;
function __construct($sql,$page,$pagesize){
  $this->sql = $sql;
  $this->page = $page;
  $this->countpage = $countpage;
  $this->pagesize = $pagesize;
  parent::__construct();
  $result = parent::query($sql);
  $num = parent::count_row($result);
  $this->countpage = ceil($num/$pagesize);
  $a = ($page-1)*$pagesize;
  $limit = "limit $a,$pagesize";
  $this->sql = $sql.$limit;
  $this->result = parent::query($this->sql);
}
function getlimit(){
  return $this->sql;
}
    function next(){
     return parent::next($this->result);
    }
function foor(){
  $a = $this->page -1;
  $b = $this->page +1;
  if ($this->page == 1) {
   echo "首页"."    ";
  }else  echo "<a href='?page=1'>首页</a>"."    ";
  if($this->page >1)
     echo "<a href='?page=$a'>上页</a>"."    ";
  else  echo "上页    ";
  for ($i =1;$i <= $this->countpage;$i++){
   echo "<a href='?page=$i'>$i</a>"."       ";
  }
  if($this->page < $this->countpage)
      echo "<a href='?page=$b'>下页</a>"."    ";
  else  echo "下页    ";
  if ($this->page == $this->countpage) {
   echo "末页"."    ";
  }else   echo "<a href='?page=$this->countpage'>末页</a>";
  #######################
 
}
}
####################
if (isset($_GET['page'])) {
$page = $_GET['page'];
}else  $page = 1;
$sql = "select * from guestbook ";
$pagesize =3;
$p = new fenye($sql,$page,$pagesize); 
$sql = $p->getlimit();
$result = $p->query($sql);
while($row = $p->next()){
echo $row['id']."<br>";
}
$p->foor();
$p->close($result);
?>

$result = pg_query($pgsql_conn, "INSTER INTO topic (man, mail, title, content) VALUES ('$name', '$mail', '$title', '$content');");
if(!$result){
        echo "An error occured.n";
        exit;
}

 

$pgsql_conn = pg_connect("host=localhost port=5432 dbname=book user=vi");
if (!$pgsql_conn) {
   echo "connect database error.n";
   exit;
}

本文由宝马娱乐在线城发布于互联网络,转载请注明出处:php分页类宝马娱乐在线

关键词: