簡體   English   中英

數據表不適用於php

[英]datatables not working with php

我有一個包含動態內容的數據表,該表是從mysql數據庫中獲取的。 如果我沒有記錄,則該表會正確顯示搜索欄ETC。 但是,一旦我添加了數據,它就會刪除thead中的搜索按鈕,分頁和排序選項。

這是我的代碼:

在標題中:

    <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script src="https://datatables.net/examples/resources/demo.js"></script>

    <script type="text/javascript" class="init">
$(document).ready(function() {
    $('#userstable').DataTable( {
        "language": {
            "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Hebrew.json"
        }
    } );
} );

    </script>
<link rel="stylesheet" href="assets/css/datatables.css">

在身體里:

    <table id="userstable" class="table display" style="width:100%">
        <thead>
                <th class="text-center">תמונה</th>
                <th class="text-center">שם פרטי</th>
                <th class="text-center">שם משפחה</th>
                <th class="text-center">שם משתמש</th>
                <th class="text-center">דוא"ל</th>
                <th class="text-center">קבוצה</th>
                <th class="text-center">פעיל</th>
                <th class="text-center">נוצר ב</th>
                <th class="text-center">עריכה</th>
                <th class="text-center">מחיקה</th>

        </thead>
        <tbody>

<?php

                           while($row = mysqli_fetch_assoc($result)){

                            echo "<tr>
                            <td class='text-center'>" . $row['avatar'] . "</td>
                            <td class='text-center'>" . $row['firstName'] . "</td>
                            <td class='text-center'>" . $row['lastName'] . "</td>
                            <td class='text-center'>" . $row['username'] . "</td>
                            <td class='text-center'>" . $row['email'] . "</td>
                            <td class='text-center'>" . $row['userGroup'] . "</td>
                            <td class='text-center'>" . $row['active'] . "</td>
                            <td class='text-center'>" . $row['userGroup'] . "</td>
                            <td class='text-center'><a href='edituser.php?id=" . $row['id'] . "' type='button' class='btn btn-info'>עריכה</td>
                            <td class='text-center'><a href='deleteuser.php?id=" . $row['id'] . "' type='button' class='btn btn-danger'>מחיקה</td>
                            <tr>";

                            }  

?>
        </tbody>
    </table>

這是顯示問題的簡短視頻:

http://recordit.co/sfuMTXW7Be

先感謝您。

我發現了問題...我沒有關閉表格最后2個td中的a標簽...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM