PHP PDO Paging

Source: Internet
Author: User

<table width= "95%" border= "1" cellspacing= "0" cellpadding= "0" align= "center" > <tr align= "center" height= "30p X "> <td> article title </td> <td> article content </td> <td> edit </td> </ Tr> <?PHPTry{        Header("content:text/html; Charset:utf-8 "); include"Conn/conn.php"; if(@$_get[' Page ']!= ' "){            $page=$_get[' Page ']; }Else{            $page=1; }        if($page){            $page _size=5; $query= "SELECT count (*) as Total from Tb_affiche"; $result _acticle=$pdo->prepare ($query); $result _acticle-execute (); $msg _count=$result _acticle->rowcount ($result _acticle, 0, "total"); $page _count=Ceil($msg _count/$page _size); $offset=($page-1) *$page _size; $sql= "SELECT * from Tb_article ORDER BY" desc limit$offset,$page _size"; if(@$_post[' Btnsea ']== ' query '){            $TXTB=$_post[' Txtbook ']; $sql= "SELECT * from Tb_article the where title like '%".Trim($TXTB)." % ' or content like '% '.Trim($TXTB)." % ' ORDER BY now DESC limit 5 '; }        $result _acticle=$pdo->prepare ($sql); $result _acticle-execute ();  while($res _article=$result _acticle->fetch (PDO::Fetch_assoc)) {            ?> <tr height= "30px" > <td align= "center" ><?phpEcho $res _article[' title '];?></td> <td>&nbsp;<?phpEcho $res _article[' content '];?></td> <td width= "50px" align= "center" ><a href= "modify.php?id=" <?php Echo$res _article[' id '];?> ' "> Edit </a></td> <td width=" 50px "align=" center "><a href=" delete.php?id= "<?ph P Echo$res _article[' id '];?> ' "> Delete </a></td> </tr> <?php}} }Catch(Exception $ex){            Echo $ex-GetMessage (); }></table><table align= "center" width= "" "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "> <tr> <td> page: <?phpEcho $page? >/<?phpEcho $page _count?> page &nbsp; record: <?phpEcho $msg _count?> </td> <td>&nbsp;</td> <td width= "40px" ><a href= "edit.php?page=1" > Home </a></td> <td width= "45px" ><a href= "edit.php?page=<?php if ($page==1) {echo"1"; }else{Echo$page-1; }?>"> Prev </a></td> <td width=" 45px "><a href="edit.php?page=<?php if ($page==$page _count) {echo$page _count; }else{Echo$page+1; }?>"> Next </a></td> <td width=" 40px "><a href=" edit.php?page=<?php Echo$page _count?> "> Last </a></td> </tr> </table>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.