首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >表中没有可用的数据,但显示了来自数据库的数据。

表中没有可用的数据,但显示了来自数据库的数据。
EN

Stack Overflow用户
提问于 2016-08-02 09:33:24
回答 2查看 2.3K关注 0票数 1

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

代码语言:javascript
复制
<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>

-

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

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-08-02 09:49:21

  1. method = "post"标记中删除<table>
  2. 为什么两个<tbody>标签出现在<table>中。移除一个。
  3. 为什么</td>还没有打开的时候就关闭了。
  4. 没有打开<tr>

更新代码:

代码语言:javascript
复制
<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

票数 2
EN

Stack Overflow用户

发布于 2016-08-02 09:40:15

这是因为您错过了一个tr,而是在这里的回波中回显</td>

代码语言:javascript
复制
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>";
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38716757

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档