• <legend id='zQom1'><style id='zQom1'><dir id='zQom1'><q id='zQom1'></q></dir></style></legend>
    <tfoot id='zQom1'></tfoot>
  • <i id='zQom1'><tr id='zQom1'><dt id='zQom1'><q id='zQom1'><span id='zQom1'><b id='zQom1'><form id='zQom1'><ins id='zQom1'></ins><ul id='zQom1'></ul><sub id='zQom1'></sub></form><legend id='zQom1'></legend><bdo id='zQom1'><pre id='zQom1'><center id='zQom1'></center></pre></bdo></b><th id='zQom1'></th></span></q></dt></tr></i><div id='zQom1'><tfoot id='zQom1'></tfoot><dl id='zQom1'><fieldset id='zQom1'></fieldset></dl></div>

    <small id='zQom1'></small><noframes id='zQom1'>

          <bdo id='zQom1'></bdo><ul id='zQom1'></ul>

        搜索高级 php/mysql 分页脚本

        Searching for advanced php/mysql pagination script(搜索高级 php/mysql 分页脚本)
          <tbody id='O0VdD'></tbody>

          <i id='O0VdD'><tr id='O0VdD'><dt id='O0VdD'><q id='O0VdD'><span id='O0VdD'><b id='O0VdD'><form id='O0VdD'><ins id='O0VdD'></ins><ul id='O0VdD'></ul><sub id='O0VdD'></sub></form><legend id='O0VdD'></legend><bdo id='O0VdD'><pre id='O0VdD'><center id='O0VdD'></center></pre></bdo></b><th id='O0VdD'></th></span></q></dt></tr></i><div id='O0VdD'><tfoot id='O0VdD'></tfoot><dl id='O0VdD'><fieldset id='O0VdD'></fieldset></dl></div>
        • <tfoot id='O0VdD'></tfoot>

            <small id='O0VdD'></small><noframes id='O0VdD'>

            <legend id='O0VdD'><style id='O0VdD'><dir id='O0VdD'><q id='O0VdD'></q></dir></style></legend>

              • <bdo id='O0VdD'></bdo><ul id='O0VdD'></ul>

                  本文介绍了搜索高级 php/mysql 分页脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在寻找一个高级"的 php 分页脚本,每页显示 10 个 mysql 条目.在网络上有许多简单"脚本(即使使用 jQuery),如下所示: http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html这是一个演示:http://demos.9lessons.info/pagination.php>

                  当有数百个条目时,这些简单的脚本很糟糕......所以我需要一个高级脚本 - 我需要这样的东西:

                  当您在第 1 页时,它应该如下所示:

                  [1] 2 3 4 5 ... 45

                  在第 8 页:

                  1 ... 6 7 [8] 9 10 ... 45

                  第 43 页:

                  1 ... 41 42 [43] 44 45

                  等等...

                  许多论坛或博客(例如 wordpress)都在使用这种技术.有人可以给我提供代码吗?一定有最佳实践代码",但我找不到.谢谢!

                  解决方案

                  试试这个,

                  function generatePagination($currentPage, $totalPages, $pageLinks = 5){如果 ($totalPages <= 1){返回空;}$html = '
                    ';$leeway = floor($pageLinks/2);$firstPage = $currentPage - $leeway;$lastPage = $currentPage + $leeway;如果 ($firstPage <1){$lastPage += 1 - $firstPage;$第一页 = 1;}如果 ($lastPage > $totalPages){$firstPage -= $lastPage - $totalPages;$lastPage = $totalPages;}如果 ($firstPage <1){$第一页 = 1;}如果 ($firstPage != 1){$html .= '<li class="first"><a href="./?p=1" title="第1页">1</a></li>';$html .= '<li class="页面点"><span>...</span></li>';}for ($i = $firstPage; $i <= $lastPage; $i++){如果 ($i == $currentPage){$html .= '<li class="当前页面"><span>'.$i .'</span></li>';}别的{$html .= '<li class="page"><a href="./?p='. $i .'" title="页面' . $i .'">'.$i .'</a></li>';}}如果 ($lastPage != $totalPages){$html .= '<li class="页面点"><span>...</span></li>';$html .= '<li class="last"><a href="./?p='. $totalPages .'" title="页面' . $totalPages . '">'.$totalPages .'</a></li>';}$html .= '</ul>';返回 $html;}

                  I'm searching for a "advanced" php Pagination script, that shows me 10 mysql entries per page. In the web there are many "simple" scripts (even with jQuery) like this: http://www.9lessons.info/2009/09/pagination-with-jquery-mysql-and-php.html Here is a demo: http://demos.9lessons.info/pagination.php

                  These simple scripts are bad when having hundreds of entries... So what I need is an advanced script - I need something like this:

                  When you are on Page 1 it should look like this:

                  [1] 2 3 4 5 ... 45
                  

                  On Page 8:

                  1 ... 6 7 [8] 9 10 ... 45
                  

                  On Page 43:

                  1 ... 41 42 [43] 44 45
                  

                  and so on...

                  Many forums or blogs (e.g. wordpress) are using this technique. Can somebody please provide me with the code? There must be a "best practise code", but I can't find it. Thanks!

                  解决方案

                  Try this out,

                  function generatePagination($currentPage, $totalPages, $pageLinks = 5)
                  {
                      if ($totalPages <= 1)
                      {
                          return NULL;
                      }
                  
                      $html = '<ul class="pagination">';
                  
                      $leeway = floor($pageLinks / 2);
                  
                      $firstPage = $currentPage - $leeway;
                      $lastPage = $currentPage + $leeway;
                  
                      if ($firstPage < 1)
                      {
                          $lastPage += 1 - $firstPage;
                          $firstPage = 1;
                      }
                      if ($lastPage > $totalPages)
                      {
                          $firstPage -= $lastPage - $totalPages;
                          $lastPage = $totalPages;
                      }
                      if ($firstPage < 1)
                      {
                          $firstPage = 1;
                      }
                  
                      if ($firstPage != 1)
                      {
                          $html .= '<li class="first"><a href="./?p=1" title="Page 1">1</a></li>';
                          $html .= '<li class="page dots"><span>...</span></li>';
                      }
                  
                      for ($i = $firstPage; $i <= $lastPage; $i++)
                      {
                          if ($i == $currentPage)
                          {
                              $html .= '<li class="page current"><span>' . $i . '</span></li>';
                          }
                          else
                          {
                              $html .= '<li class="page"><a href="./?p=' . $i . '" title="Page ' . $i . '">' . $i . '</a></li>';
                          }
                      }
                  
                      if ($lastPage != $totalPages)
                      {
                          $html .= '<li class="page dots"><span>...</span></li>';
                          $html .= '<li class="last"><a href="./?p=' . $totalPages . '" title="Page ' . $totalPages . '">' . $totalPages . '</a></li>';
                      }
                  
                      $html .= '</ul>';
                  
                      return $html;
                  }
                  

                  这篇关于搜索高级 php/mysql 分页脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <tbody id='Z8869'></tbody>

                  • <tfoot id='Z8869'></tfoot>

                    <i id='Z8869'><tr id='Z8869'><dt id='Z8869'><q id='Z8869'><span id='Z8869'><b id='Z8869'><form id='Z8869'><ins id='Z8869'></ins><ul id='Z8869'></ul><sub id='Z8869'></sub></form><legend id='Z8869'></legend><bdo id='Z8869'><pre id='Z8869'><center id='Z8869'></center></pre></bdo></b><th id='Z8869'></th></span></q></dt></tr></i><div id='Z8869'><tfoot id='Z8869'></tfoot><dl id='Z8869'><fieldset id='Z8869'></fieldset></dl></div>
                    • <bdo id='Z8869'></bdo><ul id='Z8869'></ul>

                      <small id='Z8869'></small><noframes id='Z8869'>

                          <legend id='Z8869'><style id='Z8869'><dir id='Z8869'><q id='Z8869'></q></dir></style></legend>