• 关于网站分页


    今天写代码遇到写一个分页,而以前写的分页自己又不太满意,就重新写了一个。

    效果如图:

    写完后,感觉代码太多,不太完善,不过功能实现了

          <?php
            switch ($page)
            {
                case 1:
                  echo '<div class="movie_page"><a href="?page=1#all">首页</a><span >1</span><a href="?page=2#all" >2</a><a href="?page=3#all"> 3</a> <a href="?p              age=4#all">4</a> <a href="?page=5#all">5</a> <a href="?page='.$total_page.'#all">末页</a>
                          <div class="movie_page_total"><font>1</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
                  break;
                case 2:
                   echo '<div class="movie_page"><a href="?page=1#all">首页</a><a href="?page=1#all">1</a><span >2</span><a href="?page=3#all">3</a> <a href="?pa              ge=4#all">4</a> <a href="?page=5#all">5</a> <a href="?page='.$total_page.'#all">末页</a>
                          <div class="movie_page_total"><font>2</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
                  break;
                case 3:
                   echo '<div class="movie_page"><a href=?page=1#all"">首页</a><a href="?page=1#all">1</a><a href="?page=2#all">2</a><span >3</span><a href="?pag              e=4#all">4</a> <a href="?page=5#all">5</a> <a href="?page='.$total_page.'#all">末页</a>
                          <div class="movie_page_total"><font>3</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
                  break;
                case 4:
                      echo '<div class="movie_page"><a href="?page=1#all">首页</a><a href="?page=1#all">1</a><a href="?page=2#all">2</a><a href="?page=3#all">3</              a><span >4</span> <a href="?page=5#all">5</a> <a href="?page='.$total_page.'#all">末页</a>
                          <div class="movie_page_total"><font>4</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
                      break;
                case 5:
                          echo '<div class="movie_page"><a href="?page=1#all">首页</a><a href="?page=1#all">1</a><a href="?page=2#all">2</a><a href="?page=3#all">3</a> <a href="?page=4#all">4</a><span >5</span> <a href="?page='.$total_page.'#all">末页</a>
                        <div class="movie_page_total"><font>5</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
                          break;
                default:
                  echo '<div class="movie_page"><a href="?page=1#all">首页</a><a href="?page=1#all"><span>1</span onclick="showMovieChange("'.$arr_cinema[($page-            1)*$pageSize][0].'");"></a><a href="?page=2#all">2</a><a href="?page=3#all">3</a> <a href="?page=4#all">4</a> <a href="?page=5#all">5</a            > <a href="?page='.$total_page.'#all">末页</a>
                        <div class="movie_page_total"><font>1</font><font>/</font><font>'.$total_page.'</font></div>
                          </div>';
            }
            ?>

    其中的#all,是为了点击页码,页面刷新时加的锚点,我用的是Id。

    代码太多,而且还不通用,先记下来,以后有时间写成一个分页类。

    加油,↖(^ω^)↗!

    千里之行,始于足下。改变现在,就是改变未来。改变未来,从现在开始。 个人网站:http://www.wangkongming.cn
  • 相关阅读:
    django media配置
    django model项目外操作
    django 快捷代码提示
    django静态文件路径配置
    selenium爬取网易云
    selenium
    pyquery
    beautifulsoup
    Kafka与.net core(三)kafka操作
    Oracle 日期类型timestamp(时间戳)和date类型使用
  • 原文地址:https://www.cnblogs.com/wangkongming/p/2717247.html
Copyright © 2020-2023  润新知