• 分页效果的实现


    $pagnow当前页
    $pagecount总页数
    if($pagenow>1){
        $prepage=$pagenow-1;
    echo "<a href='f.php?pagenow=$prepage'>上一页</a>";
    }
    if($pagenow<$pagecount){
        $nexpage=$pagenow+1;
    echo "<a href='f.php?pagenow=$nexpage'>下一页</a>";
    }
    显示当前页和共有多少页
    echo "当前页{$pagenow}/共{$pagecount}页";
    打印出页码的超链接
    方法一:
    for($i=1;$i<=$pagecount;$i++){
        echo "<a href='f.php?pagenow=$i'>$i</a>&nbsp";
    }
    方法二:
    for($j=1;$j<=$pagecount;$j++){
    if($currpage == $j){
       echo $j.'&nbsp;';
    continue;
    }
        echo "<a href='?p=$j'>$j</a>&nbsp;";
    }
    <a href="?p=1">首页</a>
    <a href="?p=<?=$currpage+1?>">下页</a>
    <a href="?p=<?php echo $currpage-1;?>">上页</a>
    <a href="?p=<?=$pagecount?>">末页</a>
    1. <!doctype html>
    2. <html>
    3. <head>
    4. <meta charset="utf-8">
    5. <title>webrx-php</title>
    6. </head>
    7. <body>
    8. <?php
    9. include 'inc/db_mysqli.php';
    10. $rr = $m->query('select count(*) from member');
    11. $rs = $rr->fetch_row();
    12. $recordcount = $rs[0]; //共13条记录
    13. $pagesize = 1; //每页两条记录
    14. $pagecount = ceil($recordcount/$pagesize); //总页数
    15. $currpage = isset($_GET['p']) ? $_GET['p'] : 1;//当前页
    16. $currpage = $currpage<=1 ? 1 : $currpage;
    17. $currpage = $currpage>=$pagecount ? $pagecount : $currpage;
    18. $start = $currpage*$pagesize-$pagesize;
    19. $r = $m->query("select id,maccount,mname from member limit $start,$pagesize");
    20. while($rs = $r->fetch_row()){
    21. echo $rs[1].'<br>';
    22. }
    23. echo '<hr>';
    24. for($j=1;$j<=$pagecount;$j++){
    25. if($currpage == $j){
    26. echo $j.'&nbsp;';
    27. continue;
    28. }
    29. echo "<a href='?p=$j'>$j</a>&nbsp;";
    30. }
    31. ?>
    32. <hr>
    33. <a href="?p=1">首页</a>
    34. <a href="?p=<?=$currpage+1?>">下页</a>
    35. <a href="?p=<?php echo $currpage-1;?>">上页</a>
    36. <a href="?p=<?=$pagecount?>">末页</a>
    37. </body>
    38. </html>
    百度分页效果的实现
    $first=1;
    $end=1;
    if($currpage>=7){
        $first=$currpage-5;
        $end=$first+$end-1;
    }
    if($currpage>1){
        $pre=$currpage-1;
        echo "<a href='?p=1'>首页</a><a href='?p=$pre'>上一页</a>$nbsp;";
    }
    if($currpage<$pagecont){
        $nex=$currpage+1;
    echo "<a href='?p=$nex'>下一页</a><a href='?p=$pagecount'>尾页</a>";
    }




  • 相关阅读:
    电力基础知识培训(三)
    VB开发——打开Excel并使特定的worksheet处于激活状态
    电力基础知识培训(二)
    Professionals train themselves
    WINCE6.0 + S3C2443的启动过程nboot篇
    WINCE下如何设置/删除/查询这些环境变量
    WINCE6.0+S3C6410 watchdog重新启动
    在WinCE 6.0系统下实现USB功能定制
    在WINCE5.0开始菜单中添加应用程序
    WINCE内存机制
  • 原文地址:https://www.cnblogs.com/lsr111/p/4532181.html
Copyright © 2020-2023  润新知