【问题标题】:DataTables warning (table id = 'My Table'): Requested unknown parameter '0' from the data sourceDataTables 警告(表 id =“我的表”):从数据源请求未知参数“0”
【发布时间】:2018-06-06 20:20:08
【问题描述】:

我有一个数据表来显示 MYSQL 数据库中的字段,但是我不断收到错误消息:

DataTables 警告(表 id = 'My Table'):请求未知 来自数据源的参数“0”

这是我的代码:

      <table class="table table-striped table-bordered" id="sample_1">
                              <thead>
                                 <tr>
                                    <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                                    <th>Username</th>
                                    <th class="hidden-phone">Email</th>
                                    <th class="hidden-phone">Points</th>
                                    <th class="hidden-phone">Joined</th>
                                    <th class="hidden-phone"></th>
                                 </tr>
                              </thead>
                              <tbody>
 <?php


$con = mysql_connect("localhost","cl49-XXX","XXX");
if (!$con) 
  {
   die('Could not connect: ' . mysql_error());
   }

mysql_select_db("cl49-XXX", $con)or die( "Unable to select database");


$result=mysql_query("SELECT * FROM products ")or die('You need enter a catagory ' );

  echo "<tr>"; // first row beginning
for ($i = 1; $i <= mysql_num_rows($result); $i++)
{
    $row = mysql_fetch_array($result);

    $prodname = $row['prodname'];
    $prodID = $row['prodID'];
    $catagory = $row['catagory'];

                      echo "<tr class='odd gradeX'>
                                          <td><input type='checkbox' class='checkboxes' value='1'/></td>

                      <td class='hidden-phone'>$prodID</td>
                      <td class='hidden-phone'>$prodname</td>
                                            <td class='hidden-phone'>$catagory</td>
                                            <td class='hidden-phone'><a href='deleteproduct.php?q=$prodID'><button class='btn btn-danger'type='submit'><font color='white'>Delete</font>  </a>
                                            ";


        echo "</tr><tr>"; // it's time no move to next row

}
echo "</tr>"; // last row ending
    ?>
    </tbody>
    </table>     

有人知道这个错误是什么意思吗?

【问题讨论】:

  • 代码在哪里引发了错误?
  • 我找不到那个?我不确定?

标签: php mysql html-table


【解决方案1】:

td 的数量应该与你在调用 datatable() 时给出的数量相匹配;

快速修复(如果您不想自定义默认功能)将是:

$('#sample_1').dataTable();

如果您在 datatable({/configs/}) 中提供了任何内容,只需将其完全删除,它应该可以正常工作。

【讨论】:

    猜你喜欢
    • 2014-04-15
    • 2013-11-15
    • 2013-07-19
    • 2014-09-07
    • 2013-05-08
    • 1970-01-01
    • 1970-01-01
    • 2013-09-30
    • 2019-01-25
    相关资源
    最近更新 更多