首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在引导数据库表中分页

在引导数据库表中分页
EN

Stack Overflow用户
提问于 2018-06-09 07:35:14
回答 1查看 1.6K关注 0票数 -4

我在bootstrap中有一个表,它有无限的条目,我想给它自动分页的意思,通过增加条目自动增加分页数量。

代码语言:javascript
复制
<table class="table table-hover" align="center" border="2" style="text-align:center">

    <tr height="">
            <td><b>S.NO</b></td>
            <td><b>DESRIPTION</b></td>
            <td><b>RECIEVE</b></td>
            <td><b>SENT</b></td>
            <td><b>AVAILABLE BALANCE</b></td>
        </tr>
        <?php
        $i=1; 
        $query = mysqli_query($con , "select * from income where userid='$searchid'  ORDER BY `id` DESC");

        if(mysqli_num_rows($query)>0){
            while($row = mysqli_fetch_array($query)){?>
            <tr>
                <td><b><?php echo $i++;?></b></td>
                <td><?php echo $row['description'] ; ?></td>
                <td><?php echo $row['received'] ; ?></td>
                <td><?php echo $row['sent'] ; ?></td>
                <td><?php echo $row['current_bal'] ; ?></td>
            </tr>
            <?php
        }}else{?>
            <tr>
                <td colspan='5'>NO Record Found</td>
            </tr>
        <?php
        }
        ?>


    </table>
EN

回答 1

Stack Overflow用户

发布于 2018-06-09 08:47:15

代码语言:javascript
复制
Here is your solution with datatables..add your php code inside tbody tag ...  

  <!DOCTYPE html>
    <html>
    <head>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />

      <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" />
      <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
        <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
        <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>
    <body>



    <table id="example" table table-bordered table-striped>

                            <thead>
                            <tr>
                                <th><b>S.NO</b></th>
                                <th><b>DESRIPTION</b></th>
                                <th><b>RECIEVE</b></th>
                                <th><b>SENT</b></th>
                                <th><b>AVAILABLE BALANCE</b></th>
                            </tr>
                            </thead>
                            <tbody>
                                <tr>
                                <td>1</td>
                                <td>qwerty</td>
                                <td>uiop</td>
                                <td>asdf</td>
                                <td>12345</td>
                                </tr>
                                    <tr>
                                <td>1</td>
                                <td>qwerty</td>
                                <td>uiop</td>
                                <td>asdf</td>
                                <td>12345</td>
                                </tr>
                                    <tr>
                                <td>1</td>
                                <td>qwerty</td>
                                <td>uiop</td>
                                <td>asdf</td>
                                <td>12345</td>
                                </tr>
                            </tbody>

                        </table>
                        <script type="text/javascript">

                           $(document).ready(function() {
        $('#example').DataTable();
    } );
                        </script>

                        </body>


    </html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50769608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档