zoukankan      html  css  js  c++  java
  • 自定义简单分页

    自定义分页

     $info1 = $GLOBALS['DB']->get_row("SELECT COUNT(*) FROM admin_trouble WHERE `engineman` = '{$_SESSION['name']}'");

    // echo $_SESSION['name'];exit;

    $count = $info1['COUNT(*)'];

    $page = $_GET['page'] ? $_GET['page'] : 1;

    $page_size = 2;

    $start = ($page-1) * $page_size;

    $end = $page_size;

    $maxpage = ceil($count/$page_size);

    $next = $page + 1;

    $prev = $page - 1;

    // echo $end;

    $info = $GLOBALS['DB']->get_results("SELECT * FROM admin_trouble WHERE `engineman` = '{$_SESSION['name']}' LIMIT $start,$end");

    // var_dump($info);exit;

    if($page == 1){

    $string  = "<li>当前是第{$page}页</li>";

    $string .="<a href=/log.php?act=fenye&page=$next>下一页</a>";

    }

    if($page > 1 && $page < $maxpage){

    $string = "<li><a href=/log.php?act=fenye&page=$prev>上一页</a></li>";

    $string .="<li><a href=/log.php?act=fenye&page=1>首页</a></li>";

    $string .= "<li>当前是第{$page}页</li>";

    $string .="<li><a href=/log.php?act=fenye&page=$next>下一页</a></li>";

    }

    if($page == $maxpage){

    $string = "<li><a href=/log.php?act=fenye&page=1>首页</a></li>";

    $string .= "<li>当前是第{$page}页</li>";

    $string .="<li><a href=/log.php?act=fenye&page=$prev>上一页</a></li>";

    }

  • 相关阅读:
    [LeetCode] 617. Merge Two Binary Trees
    [LeetCode] 738. Monotone Increasing Digits
    289. Game of Life
    305. Number of Islands II
    288. Unique Word Abbreviation
    271. Encode and Decode Strings
    393. UTF-8 Validation
    317. Shortest Distance from All Buildings
    286. Walls and Gates
    296. Best Meeting Point
  • 原文地址:https://www.cnblogs.com/xionghao/p/6781260.html
Copyright © 2011-2022 走看看