2016-08-02 74 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>"; 
} 
相關問題