zoukankan      html  css  js  c++  java
  • 自己写的百度分页效果含样式

    1. <!DOCTYPE html>
    2. <html>
    3. <head>
    4. <meta charset="utf-8">
    5. <title>分页</title>
    6. <style>
    7. .page{height:30px;padding:15px;clear:both;text-align:center;}
    8. .page a{padding:0px 10px;text-decoration:none;display:inline-block;margin-right:5px;border:solid 1px #c8c7c7;40px;height:35px;line-height:35px;font-size:13px;}
    9. .page a:hover,.page a.checked{text-decoration:none;border:solid 1px #0086d6;background:#0091e3;color:#fff;}
    10. .page a.pages{
    11. font-weight:800;
    12. padding:0px
    13. 10px;text-decoration:none;display:inline-block;margin-right:5px;width:40px;height:35px;line-height:35px;font-size:13px;border:none;
    14. }
    15. </style>
    16. </head>
    17. <body>
    18. <?php
    19. include 'mysqli.php';
    20. $rr=$m->query('select count(*) from member');
    21. $rs=$rr->fetch_row();
    22. $recordcount=$rs[0];//共14条记录
    23. $pagesize=1;//每页2条记录
    24. $pagecount=ceil($recordcount/$pagesize);//总共有几页
    25. $currpage=isset($_GET['p']) ? $_GET['p']:1;//显示当前页
    26. $currpage=$currpage<1 ? 1 :$currpage;
    27. $currpage=$currpage>$pagecount ? $pagecount : $currpage;
    28. $start=$currpage*$pagesize-$pagesize;
    29. $r=$m->query("select id,maccount,mname from member limit $start,$pagesize");//里面用变量了所以外面要用单引号
    30. while($rs=$r->fetch_row()){
    31. echo $rs[1].'<br>';
    32. }
    33. $st = 1;
    34. $en = 10;
    35. if($currpage>=6){
    36. $st=$currpage-5;
    37. $en=$st+$en-1;
    38. }
    39. ?>
    40. <hr>
    41. <div class="page">
    42. <?php
    43. if($currpage>1){
    44. $pre=$currpage-1;
    45. if($st>1){
    46. echo "<a href='?p=1'>首页</a><a href='?p=$pre'>上一页</a>";
    47. }else{
    48. echo "<a href='?p=$pre'>上一页</a>";
    49. }
    50. }
    51. for($j=$st;$j<=$en;$j++){
    52. if($j>$pagecount){
    53. break;
    54. }
    55. if($currpage==$j){
    56. echo "<a class='pages checked'>$j</a>&nbsp;";
    57. continue;
    58. }
    59. echo "<a href='?p=$j'>$j</a>&nbsp;";
    60. } if($currpage<$pagecount){
    61. $nex=$currpage+1;
    62. if($en<$pagecount){
    63. echo "<a href='?p=$nex'>下一页</a><a href='?p=$pagecount'>尾页</a>";
    64. }else{
    65. echo "<a href='?p=$nex'>下一页</a>";
    66. }
    67. }
    68. // echo "当前页{$currpage}/共{$pagecount}页";
    69. ?>
    70. </div>
    71. </body>
    72. <html>





  • 相关阅读:
    两台虚拟机(不同电脑)通信
    虚拟机使用网络助手
    strcpy_s
    线程创建几种方法
    JavaWeb——EL详解
    JavaWeb_EL语法
    JavaWeb_JavaBean
    JavaWeb_HttpSession之验证码
    JavaWeb_HttpSession之表单的重复提交
    JavaWeb——相对路径和绝对路径
  • 原文地址:https://www.cnblogs.com/lsr111/p/4532203.html
Copyright © 2011-2022 走看看