2016-08-02 10 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> 

せずにデータを表示 - あなたはtrを逃し、代わりにあなたがここにエコーで</td>をエコーためだ

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

enter image description here

+0

しているのですか?!? – arkascha

+0

データ型のみを使用してデータを表示する場合は、間違っていると思われます。をhtml/phpファイルに追加する必要があります。[link] https://datatables.net/examples/server_side/simple.htmlをご確認ください –

答えて

2
  1. method = "post"<table>タグから削除します。
  2. なぜ2つ<tbody>タグが内部にあります<table>です。 1つを削除します。
  3. なぜ</td>はまだ開かれていないときに閉じていますか?
  4. いいえ<tr>が開かれました。

のUPDATE CODE:

<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> 

[NOTE: `method`属性は` table`タグ内に何をThe mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead

+1

考えられるすべての問題を修正し、特別に注意するための+10 –

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>"; 
} 
関連する問題