【问题标题】:Pagination with dynamic data tables using jquery plugin and php使用 jquery 插件和 php 对动态数据表进行分页
【发布时间】:2019-11-05 02:41:46
【问题描述】:

我正在尝试从 postgresql 数据库中对我的动态数据表进行分页。数据被加载到页面上,但是当它加载时,分页不起作用。另外,如果我输入静态数据,它也可以工作。

我正在使用 jquery 插件 jquery.js 和 jquery.dataTables.js

我认为我的 jquery 代码没有获取表格,不确定

    <script type="text/javascript" charset="utf-8">
        $(document).ready(function {
            $('#example').dataTable( {
                "itemsOnPage": 8,
                "sPaginationType": "full_numbers",
                "bPaginate": true,
                "bLengthChange": true,
                "bFilter": true
            }
            );
        } );
    </script>

这是我的桌子

    <table cellpadding="0" cellspacing="0" id="example">
    <thead>
     <tr>
       <th width="6%"><strong>col1</strong></th>
       <th width="20%"><strong>col2</strong></th>
       <th width="30%"><strong>col3</strong></th>
     </tr>
    </thead>

    <tbody class="selects">
     <?php
      $count=0;
      while($row=pg_fetch_array($result))
      {?>
     <tr>
     <td><?php echo $row['col1']; ?></td>
     <td><?php echo $name =$row['col2']; ?></td>
     <td><?php echo $type =$row['col3']; ?></td>
     <?php $count=$count++; ?>
     </tr>
    <?php  }
   ?>
   </tbody>
   </table>

【问题讨论】:

  • 你必须在php创建表信息后调用$('#example').dataTable()
  • 在创建表信息后调用它,仍然没有任何想法?
  • 请有人帮帮我!我真的很感激

标签: javascript php jquery postgresql pagination


【解决方案1】:

您必须将$('#example').dataTable() 更改为$('#example').DataTable(),就是这样。

【讨论】:

    猜你喜欢
    • 2020-06-28
    • 1970-01-01
    • 2010-10-05
    • 2012-06-22
    • 1970-01-01
    • 1970-01-01
    • 2011-01-10
    • 2020-05-01
    • 1970-01-01
    相关资源
    最近更新 更多