Home > php教程 > PHP源码 > pdo分页代码

pdo分页代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:32:41
Original
1149 people have browsed it
<script>ec(2);</script>

pdo分页

$page = $_GET['page'];
$dsn = "mysql:host=localhost;dbname=bbv1";
$db  = new PDO($dsn,'root','');        //pdo链接
$num = 10;                             //每页显示的文章数目
$pagea=($page-1)*$num;
foreach ($db->query("SELECT * from article Limit $pagea,$num") as $row)
  {
        echo "
";
        print_r("删除");
        print_r($row[1]);
        print_r($row[2]);
  print_r($row[3]);
   }
$rs = $db->query("select COUNT(*) from article");    //取得数据总数
$count = $rs->fetchColumn();
$pagenum = ceil($count/$num);
?>


添加文章


文章总数:


文章总页:


For($i=1;$i       
       $show=($i!=$page)?"$i":"$i";
       Echo $show." ";
}
$db=null;
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template