使用自定义页面选择下拉菜单的PHP引导分页

使用自定义页面选择下拉菜单的PHP引导分页,php,jquery,html,twitter-bootstrap,Php,Jquery,Html,Twitter Bootstrap,对于当前的编码,我只想显示5个分页字段(如果适合)和记录数,否则,如果每页记录数和用户选择数据数较低,则自动调整 对于示例数据库的测试使用国家/地区列表:在图片中,它是这样的: 对于更大的数据,这种方式看起来并不好。 另外,我还添加了一个下拉列表,用户可以跳转到任何页面。但这不适用于当前的编码&for循环结构 编码部分: <div class="form-group"> <?php // display the links

对于当前的编码,我只想显示5个分页字段(如果适合)和记录数,否则,如果每页记录数和用户选择数据数较低,则自动调整

对于示例数据库的测试使用国家/地区列表:在图片中,它是这样的:

对于更大的数据,这种方式看起来并不好。 另外,我还添加了一个下拉列表,用户可以跳转到任何页面。但这不适用于当前的编码&for循环结构

编码部分:

  <div class="form-group">
             <?php
           // display the links to the pages
           // setting up the Prev & First Button
             if($page == 1){
                echo '<ul class="pagination"><li class="disabled"><a 
                href="test_cas.php?page=1">First</a></li>';
                echo '<li class="disabled"><a href="test_cas.php?
                page='.$page.'">Prev</a></li>';
               }
        else {
               echo '<ul class="pagination"><li><a href="test_cas.php?
               page=1">First</a></li>';
               echo '<li><a href="test_cas.php?page='.($page-1).'">Prev</a>
              </li>';
             }
               $before_loop_value=$page;
         for ($page=1;$page<=$number_of_pages;$page++) {
             echo '<li><a href="test_cas.php?page=' . $page . '">' . $page . 
                '</a><li>';   
           }
          // Setting up the Next & Last Button
         if($before_loop_value == $number_of_pages){
             echo'<li class="disabled"><a href="test_cas.php?page='.($page-
              1).'">Next</a></li>';
              echo '<li class="disabled"><a href="test_cas.php?
               page='.$number_of_pages.'">Last</a></li></ul>';
           }
        else {
             echo'<li><a href="test_cas.php?page='.($page-1).'">Next</a>
             </li>';  
             echo '<li><a href="test_cas.php?
             page='.$number_of_pages.'">Last</a></li>';
             }
              // Jump to a page Drop Down Section
                  echo '<select class="form-control" id="custom_page" 
                  name="custom_page">';
                  echo "<option value='" . $page . "'>" . $page . "
                  </option>";
                  echo'</select>';
                   echo'</ul>';
                     ?> 
                 </div>
                 <div class="form-group">Total Record <?php echo 
                    $number_of_results?>
                 </div>

总记录
Bootstrap有一个选项用于
  • 但不确定如何使用此结构实现它。我们将非常感谢您的帮助

    阿里·齐亚的回答是: 我已经添加了以下链接:

    
    
    使用此样式

    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.min‌​.css">
    
    用以下格式制作HTML

    <table id="datatable" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>Tiger Nixon</td>
                    <td>System Architect</td>
                    <td>Edinburgh</td>
                    <td>61</td>
                    <td>2011/04/25</td>
                    <td>$320,800</td>
                </tr>
                <tr>
                    <td>Garrett Winters</td>
                    <td>Accountant</td>
                    <td>Tokyo</td>
                    <td>63</td>
                    <td>2011/07/25</td>
                    <td>$170,750</td>
                </tr>
                <tr>
                    <td>Ashton Cox</td>
                    <td>Junior Technical Author</td>
                    <td>San Francisco</td>
                    <td>66</td>
                    <td>2009/01/12</td>
                    <td>$86,000</td>
                </tr>
            </tbody>
        </table>
    
    
    名称
    位置
    办公室
    年龄
    开始日期
    薪水
    名称
    位置
    办公室
    年龄
    开始日期
    薪水
    老虎尼克松
    系统架构师
    爱丁堡
    61
    2011/04/25
    $320,800
    加勒特温特斯
    会计
    东京
    63
    2011/07/25
    $170,750
    阿什顿考克斯
    初级技术作者
    旧金山
    66
    2009/01/12
    $86,000
    
    除此之外,您还可以使用数据表。:)谢谢,但是我已经有了mysql的bootstrap表,如何实现。我检查了它,它看起来很漂亮,比我的一整页代码要好,但它不是免费的。它绝对免费。谢谢你让我试试,然后再给你回复。如果它不起作用,你可以检查下面底部的链接,有javascript、HTML和CSS。你可以从那里获得帮助。是的,删除所有代码。加载此表中的所有数据。这将自动分页。请看这里
    $(document).ready(function() {
        $('#datatable').DataTable();
    });
    
    <table id="datatable" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>Tiger Nixon</td>
                    <td>System Architect</td>
                    <td>Edinburgh</td>
                    <td>61</td>
                    <td>2011/04/25</td>
                    <td>$320,800</td>
                </tr>
                <tr>
                    <td>Garrett Winters</td>
                    <td>Accountant</td>
                    <td>Tokyo</td>
                    <td>63</td>
                    <td>2011/07/25</td>
                    <td>$170,750</td>
                </tr>
                <tr>
                    <td>Ashton Cox</td>
                    <td>Junior Technical Author</td>
                    <td>San Francisco</td>
                    <td>66</td>
                    <td>2009/01/12</td>
                    <td>$86,000</td>
                </tr>
            </tbody>
        </table>