2016-08-02 16 views
1

Die Datentabelle zeigt den Inhalt der Datenbank an, zeigt aber immer noch eine Fehlermeldung an: In der Tabelle sind keine Daten verfügbar. wie kann ich dieses Problem beheben, zeigen nur die Daten ohne Fehlermeldungkeine Daten in der Tabelle verfügbar, aber Daten aus der Datenbank werden angezeigt

<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

Was ist das 'method' Attribut in einem' table' Tag tun?!? – arkascha

+0

Wenn Sie Daten nur mit Datenquellen anzeigen möchten, dann gehen Sie falsch. Sie müssen nur in der HTML/PHP-Datei hinzufügen, überprüfen Sie bitte [link] https://datatables.net/examples/server_side/simple.html –

Antwort

2
  1. Entfernen method = "post" von <table> Tag.
  2. Warum zwei <tbody> Tag vorhanden innerhalb <table>. Entferne eins.
  3. Warum </td> ist geschlossen, wenn es noch nicht geöffnet wurde.
  4. Nein <tr> geöffnet.

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> 

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

+1

+10 um alle möglichen Probleme zu beheben und besonders zu notieren –

0

Das ist, weil Sie ein tr und stattdessen verpasst </td> im Echo Echo hier

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>"; 
} 
Verwandte Themen