dataTables无法正常工作。链接很好,我认为。这是怎么了?

时间:2018-10-02 02:51:01

标签: javascript php html datatables

在开发方面,我还是一个新手。我只想问这段代码有什么问题?我正在尝试使用DataTables,但不幸的是,我的表仍无法正常工作。我所有的链接都正确定向到其文件夹。是链接的顺序吗?请帮助。

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">

<title>Admin Dashboard</title>
<link href="../../../vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="../../../vendor/metisMenu/metisMenu.min.css" rel="stylesheet">
<link href="../../../vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="../../../dist/css/sb-admin-2.css" rel="stylesheet">
<link href="../../../dist/dtables/dtables1/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="../../../dist/dtables/dtables1/css/dataTables.bootstrap.min.css" rel="stylesheet">

<script src="../../../dist/js/jquery-3.3.1.js"></script>
<script src="../../../vendor/jquery/jquery.min.js"></script>
<script src="../../../vendor/metisMenu/metisMenu.min.js"></script>
<script src="../../../vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="../../../dist/js/sb-admin-2.js"></script>
<script src="../../../dist/dtables/dtables1/js/jquery.dataTables.min.js"></script>
<script src="../../../dist/dtables/dtables1/js/dataTables.bootstrap.min.js"></script>
<script>
$(document).ready( function () {
    $('example').DataTable();
} );
</script>

    <div id="page-wrapper">
        <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">ITS - 101</h1>
                        <table  id="example" class="table table-striped table-bordered" style="width:100%">
                            <thead>
                                <tr>
                                    <th>Student Number</th>
                                    <th>First Name</th>
                                    <th>Middle Name</th>
                                    <th>Last Name</th>
                                    <th>Age</th>
                                </tr>
                            </thead>
                            <tfoot>
                                <tr>
                                    <th>Student Number</th>
                                    <th>First Name</th>
                                    <th>Middle Name</th>
                                    <th>Last Name</th>
                                    <th>Age</th>
                                </tr>
                            </tfoot>
                            <tbody>
                                <?php
                                    include "../../adminconn.php";

                                    $sel = "Select * from its101";

                                    $res = mysqli_query ($conn,$sel);

                                    if (mysqli_num_rows($res) > 0){

                                        while ($row = mysqli_fetch_assoc($res)){    
                                            echo "<tr><td>".$row["studentnumber"]."</td><td>".$row["fname"]."</td><td>".$row["mname"]."</td><td>".$row["lname"]."</td><td>".$row["age"]."</td></tr>";       
                                        } echo "</tbody>";
                                        echo "</table>";
                                        }else{
                                            echo "No data yet";                 
                                        }
                                    $conn -> close();
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>  
</body>

脚本和CSS是否不按顺序排列?还是桌子本身?

1 个答案:

答案 0 :(得分:-1)

我终于做到了!我只需要再次从头开始,原来jquery.dataTables.cssjquery.dataTables.js就是我所需要的,而不是jquery.dataTables.min.cssjquery.dataTables.min.js