2016-08-02 77 views
1

数据表显示数据库的内容,但仍显示错误消息:表中没有可用数据。 我如何解决这个问题,只显示数据没有错误消息表中没有可用数据,但显示数据库中的数据

<table name= "displaycase" id="example1" class="table table-bordered table-striped" method = "post"> 
    <thead> 
    <tr> 
     <th>Case Title</th> 
     <th>Court</th> 
     <th>Dockent Number</th> 
     <th>Nature</th> 
     <th>Actions Taken</th> 
     <th>Status</th> 
     <th>Due Date </th> 
    </tr> 
    </thead> 
    <tbody> 
    <tbody class = "searchable"> 
    <?php 
    if (mysql_num_rows($result) > 0) { 
     // output data of each row 
     while ($row = mysql_fetch_assoc($result)) { 
     echo 
     "</td><td>" . $row["CaseTitle"] . 
     "</td><td>" . $row["Court"] . 
     "</td><td>" . $row["docketNum"] . 
     "</td><td>" . $row["nature"] . 
     "</td><td>" . $row["actionsTaken"] . 
     "</td> <td>" . $row["status"] . 
     "</td> <td>" . $row["dueDate"] . 
     "</td></tr>"; 
     } 
    } else { 
    } 
    ?> 
    </tbody> 

-

<script> 
     $(document).ready(function() { 
     $("#example1").DataTable({ 
      "paging": false, 
      "ordering": true, 
      "info": false, 
      "language": { 
       "emptyTable": "No Data" 
      } 
      }) 
    });</script> 

enter image description here

+0

什么是'method'属性'table'标签里面做什么?!? – arkascha

+0

如果你想显示数据只使用数据表,那么你会错误..你只需要在html/php文件中添加请检查[链接] https://datatables.net/examples/server_side/simple.html –

回答

2
  1. <table>中删除method = "post"标签。
  2. 为什么两个<tbody>标签存在于<table>里面。删除一个。
  3. 为什么</td>在尚未打开时关闭。
  4. <tr>已开业。

更新代码:

<table name= "displaycase" id="example1" class="table table-bordered table-striped"> 
    <thead> 
    <tr> 
     <th>Case Title</th> 
     <th>Court</th> 
     <th>Dockent Number</th> 
     <th>Nature</th> 
     <th>Actions Taken</th> 
     <th>Status</th> 
     <th>Due Date </th> 
    </tr> 
    </thead> 

    <tbody class = "searchable"> 
    <?php 
    if (mysql_num_rows($result) > 0) { 
     while ($row = mysql_fetch_assoc($result)) { 
     echo 
     "<tr>". 
      "<td>" . $row["CaseTitle"] ."</td>". 
      "<td>" . $row["Court"] ."</td>". 
      "<td>" . $row["docketNum"] ."</td>". 
      "<td>" . $row["nature"] ."</td>". 
      "<td>" . $row["actionsTaken"] ."</td>". 
      "<td>" . $row["status"] ."</td>". 
      "<td>" . $row["dueDate"] ."</td>". 
     "</tr>"; 
     } 
    } else { 

    } 
    ?> 
    </tbody> 
</table> 

[注意The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

+1

+10以纠正所有可能的问题并特别注意 –

0

那是因为你错过了tr,而是你在回声回声</td>这里

while($row = mysql_fetch_assoc($result)) { 
    echo 
    "<tr><td>".$row["CaseTitle"]. 
    "</td><td>".$row["Court"]. 
    "</td><td>".$row["docketNum"]. 
    "</td><td>".$row["nature"]. 
    "</td><td>".$row["actionsTaken"]. 
    "</td> <td>".$row["status"]. 
    "</td> <td>".$row["dueDate"]. 
    "</td></tr>"; 
} 
相关问题