数据表警告:table = examples - 请求的未知参数' 0'第1行

时间:2016-12-12 05:16:45

标签: mysql datatables

请帮助我该怎么做才能解决这个问题?

$(document).ready(function() {
            $('#example').DataTable();
        } );

这是我的表,,,,它是错误的数据表警告:table = examples - 请求的未知参数' 0'对于第1行,最好的解决方案是什么?

<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Contact</th>
            <th>Email</th>
            <th>Username</th>
            <th>Password</th>
            <th>Date Register</th>
            <th>Action</th>
        </tr>

    </thead>
    <tbody>
      <?php
       $sql=mysql_query("SELECT * FROM user");
       while ($row=mysql_fetch_array($sql)){
            echo"<tr>
                <td>".$row['id']."</td>
                <td>".$row['name']."</td>
                <td>".$row['contact']."</td>
                <td>".$row['email']."</td>
                <td>".$row['username']."</td>
                <td>".$row['password']."</td>
                <td>".$row['RegisterDate']."</td>
                <td align='center'><a href='admin.php?epr=delete&id=".$row['id']."'>DELETE</a> |
                    <a href='admin.php?epr=update&id=".$row['id']."'>UPDATE</a>
                </td>
                <tr>";
       }
      ?>

    </tbody>
</table>

1 个答案:

答案 0 :(得分:0)

为什么要使用while ($row=mysql_fetch_array($sql))替换它 while ($row=mysqli_fetch_assoc($sql))

如果不起作用,请使用以下循环注释...

$sql=mysqli_query($connection,"SELECT * FROM user");//$connection is mysqli_connection object
       while ($row=mysql_fetch_assoc($sql)){
            echo"<tr>
                <td>".$row['id']."</td>
                <td>".$row['name']."</td>
                <td>".$row['contact']."</td>
                <td>".$row['email']."</td>
                <td>".$row['username']."</td>
                <td>".$row['password']."</td>
                <td>".$row['RegisterDate']."</td>
                <td align='center'><a href='admin.php?epr=delete&id=".$row[id]."'>DELETE</a> |
                    <a href='admin.php?epr=update&id=".$row[id]."'>UPDATE</a>
                </td>
                <tr>";
       }