DataTables在PHP页面中未显示任何内容

时间:2019-12-29 13:47:14

标签: php jquery mysql datatable

我一直在尝试在我的网站中实现数据表,但是它根本不起作用,什么也没有。 这是HTML

<?php $query = "SELECT * FROM cash_book";
$return = mysqli_query($connection, $query);
?>
<table id="table">
                    <thead>
                        <tr>
                            <th>Date of Entry</th>
                            <th>Posted By</th>
                            <th>Account Type</th>
                            <th>Project</th>
                            <th>Description</th>
                            <th>V/N0</th>
                            <th>Debit</th>
                            <th>Credit</th>
                            <th>Balance</th>
                            <th>Option</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php if ($return != false) {
                        while($result = mysqli_fetch_array($return)) {?>
                        <tr>
                            <td><?php echo $result["date"];?></td>
                            <td><?php echo $result["posted_by"];?></td>
                            <td><?php echo $result["account_type"];?></td>
                            <td><?php echo $result["project"];?></td>
                            <td><?php echo $result["description"];?></td>
                            <td><?php if($result["entry_type"] == "credit") echo "C" . $result["v_credit"]; 
                            else if ($result["entry_type"] == "debit") echo "D" . $result["v_debit"] ?></td>
                            <td><?php echo $result["debit"];?></td>
                            <td><?php echo $result["credit"];?></td>
                            <td><?php echo $balance = $result["debit"]-$result["credit"]+$balance;?></td>
                            <td><a href="entry_edit.php?id=<?php echo $result["id"]?>">Edit</a>&nbsp;&nbsp;<a href="delete.php?id=<?php echo $result["id"] ?>" onclick="return confirm('Delete this?');">Delete</a></td>


                            <?php }} ?>
                        </tr>
                    </tbody>
                </table>

这是jQuery。

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

    </script>

我已将jQuery和DataTables包含在head标签中。 而且,这就是我得到的

enter image description here

0 个答案:

没有答案