Php jQuery数据表:未捕获类型错误:无法读取属性';mData';未定义的

Php jQuery数据表:未捕获类型错误:无法读取属性';mData';未定义的,php,jquery,jquery-datatables,Php,Jquery,Jquery Datatables,为什么我会出错 未捕获的TypeError:无法读取未定义的属性“mData” 我尊重DataTables要求(我还阅读了关于我的错误的其他主题,我尊重每个答案和解决方案)。请帮帮我 以下是我的php代码: <table class="table table-striped table-bordered table-hover" id="sample_1"> <thead> <tr> &l

为什么我会出错

未捕获的TypeError:无法读取未定义的属性“mData”

我尊重DataTables要求(我还阅读了关于我的错误的其他主题,我尊重每个答案和解决方案)。请帮帮我

以下是我的php代码:

<table class="table table-striped table-bordered table-hover" id="sample_1">
        <thead>
            <tr>
                <th class="table-checkbox">
                    <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes"/>
                </th>
                <th>
                     Utilizator
                </th>
                <th>
                     Nume complet
                </th>
                <th>
                     Clasa
                </th>
                <th>
                     Functia
                </th>
                <th>
                     E-Mail
                </th>
                <th>
                     Ultima logare
                </th>
            </tr>
        </thead>
        <tbody>
            <?
               foreach($data["users"] as $student)
               {
            ?>
            <tr class="odd gradeX">
                <td>
                    <input type="checkbox" class="checkboxes" value="1"/>
                </td>
                <td>
                     <? echo $student["username"]; ?>
                </td>
                <td>
                     <? echo " ".$student["last_name"]." ".$student["first_name"].""; ?>
                </td>
                <td>
                     <? echo getclass($student["class"]); ?>
                </td>
                <td>
                     <?
                     $functie = 0;
                     if($student["role"] == 1)
                     {
                         $functie = 1;
                         echo "Administrator site";
                     }
                     if($student["fctsc"])
                     {
                         $functie = 1;
                         echo "Director";
                     }
                     if($student["diriginte"])
                     {
                         $functie = 1;
                         echo "Diriginte";
                     }
                     if($student["profesor"])
                     {
                         $functie = 1;
                         echo "Profesor";
                     }
                     if($functie == 0)
                         echo "Elev";
                     ?>
                </td>
                <td>
                    <a href="mailto:<? echo $student["email"]; ?>">
                        <? echo $student["email"]; ?>
                    </a>
                </td>
                <td class="center">
                     <? echo $student["lastlogin"]; ?>
                </td>
            </tr>
            <?
               }
            ?>
        </tbody>
    </table>

实用程序
完整核
克拉萨
Functia
电子邮件
最后通牒

检查天气是否所有php echo都在所有行上实际输出非“NULL”的内容,因为DataTables会将任何仅为NULL的单元格视为不存在的内容,这也可能导致该错误。

尽量避免将php直接输出到html表

通常出现此错误有两个原因:

  • 缺少表标题
  • 表体的
    td
    元素数与表头的
    th
    元素数不同
但是,HTML代码的列数似乎正确,请参阅


有关更多信息,请参阅。

您需要发布如何初始化dataTable!!不,我不需要。因为,如果我创建了另一个没有php代码,只有html,一切都很好。问题就在那段代码中。问题将出现在数据表初始化中!!您一定写过这样的东西
$(“#sample_1”).dataTable()发布该部分@Maurice您是否检查了最终版本(显示在浏览器中)
是否正确/有效?PHP和HTML的混合并没有真正的帮助-发布最终HTML的示例。您的脚本看起来怎么样?我想到了数据表的初始化。