douxidang9092 2017-04-30 11:45
浏览 42
已采纳

Jquery数据表未显示基本功能

When i make a normal table(without php code) it shows the datatable with all functions. But when i use php to load in my database i see the datatable, but without all functions.

What am i doing wrong? Just used the basic javascript code from the datatables website.

 <!DOCTYPE html>
    <html>
    <head>
       <title>Overzicht Exportzendingen</title>

    <meta charset="utf-8">
    <title>Exportzendingen</title>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.15/css/jquery.dataTables.css">

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
    <script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.15/js/jquery.dataTables.js"></script>

</head>
<body>
     <nav class="navbar navbar-inverse ">
          <div class="container-fluid">
            <div class="navbar-header">
              <a class="navbar-brand" href="#">Exportzendingen</a>
            </div>
            <ul class="nav navbar-nav">
              <li class="active"><a href="#">Overzicht</a></li>
            </ul>
              <a href="invoer.html" class="btn btn-default" >Zending Toevoegen</a>
          </div>
    </nav>   
    <div class="container-fluid">
     <table id="table_id" class="display table table-bordered">
        <thead>
            <tr>
            <th width="2%">ID</th>
            <th width="6%">Debiteur</th>
            <th width="10%">Klantnaam</th>
            <th width="3%">Aantal Pallets</th>
            <th width="3%">Totaal Gewicht</th>
            <th width="30%">PB Nummers</th>
            <th>Edit</th>
        </thead>
        <tbody>
            <!-- Fetch from db -->
            <!-- Connect to db-->>
         <?php
         $conn = mysqli_connect("localhost","root","","export") or die("Error in Connection");

         $query = mysqli_query($conn, "SELECT exportid, deb_nmr, cost_name, numb_pal, tot_weight, pb_s FROM export_tabel");

            while ($result = mysqli_fetch_array($query)) {
                echo "<tr>
                    <td>".$result['exportid']."</td>
                    <td>".$result['deb_nmr']."</td>
                    <td>".$result['cost_name']."</td>
                    <td>".$result['numb_pal']."</td>
                    <td>".$result['tot_weight']."</td>
                    <td>".$result['pb_s']."</td>
                </tr>";
            }

            ?>
        </tbody>
     </table> 
   </div>
            <script>    
                $(document).ready(function(){
            $('#table_id').DataTable();
                });
            </script>

    </body>
    </html>
  • 写回答

1条回答 默认 最新

  • doubishi8303 2017-04-30 12:10
    关注

    your table header has an extra column than rest of the table, so its causing errors and you could have seen the error in the JavaScript console,

    remove that extra column from table header or add suitable information in the rest of the rows, this should solve your problems

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效