How does the paging function in this package change to this effect?

Source: Internet
Author: User
Don't let it show all pages will always show only 5 pages or 10 pages just like in the picture. How should I change this code?

function Fenye () {
Global $page, $pagenum;
echo "";
echo "
      ";
      Echo '
    • '. $page. ' /'. $pagenum. ' Page |
    • ';
      if ($page ==1) {
      Echo '
    • Home |
    • ';
      Echo '
    • Prev |
    • ';
      }else{
      Echo '
    • Home |
    • ';
      Echo '
    • Prev |
    • ';
      }
      Echo ';
      Echo '
        ;
        for ($i =0; $i < $pagenum; $i + +) {
        Echo '
      • '. ($i + 1). '
      • ';
        }
        Echo '
      ;
      Echo ';
      if ($page = = $pagenum) {
      Echo '
    • | The next page |
    • ';
      Echo '
    • End |
    • ';
      }else{
      Echo '
    • | The next page |
    • ';
      Echo '
    • End |
    • ';
      }
      Echo '
';
Echo ';

};
?>


Reply to discussion (solution)

This is the database query page
!--? php
include ' fenye.php ';
Header (' content-type:text/html;charset=utf-8; ');
$pdo =new PDO ("Mysql:host=localhost;dbname=t1", "Root", "");
$stmt = $pdo->prepare ("SELECT * from Jianzhi");
$stmt->execute ();
$res = $stmt->fetchall ();
$rows =count ($res);//total number of bars
$pagesize =8;//per page
if ($rows ==0) {
$pagenum = 0;
}else{
$pagenum =ceil ($rows/$pagesize),//Divided into pages
}
if (isset ($_get[' page ')) {
$page =$_get[' page ']; br> if (Empty ($page) | | $page <0| |! Is_numeric ($page)) {
$page = 1;
}else{
$page =intval ($page);
}
}else{
$page = 1;
}
if ($page > $pagenum) {
$page = $pagenum;
}
$startnum = ($page-1) * $pagesize;
$query = "SELECT * FROM Blog LIMIT $startnum, $pagesize";
$stmt 2= $pdo->prepare ($query);
$stmt 2->execute ();
$res 2= $stmt 2->fetchall (PDO::FETCH_ASSOC);

Look at this, and you'll understand. http://www.imooc.com/learn/419

  • 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.