gpt4 book ai didi

php - jQuery DataTable 创建问题

转载 作者:行者123 更新时间:2023-12-02 19:38:28 25 4
gpt4 key购买 nike

我需要填充DIV容器,即使用jQuery DataTable创建一个表。问题是这个例子对我不起作用。我看到的不是格式化的表,而是没有任何 jQuery DataTable 插件元素的未格式化表。

下面显示的 php 文件位于文件夹 main/tables 中,而所有脚本都位于 main/scripts/media 中。

那么,我的代码到底出了什么问题?

<?php
include_once 'include/DatabaseConnector.php';
$query2="SELECT * FROM resources;";
$result2=DatabaseConnector::ExecuteQueryArray($query2);
?>

<script type="text/javascript" src="../scripts/media/js/jquery.dataTables.min.js"></script>
<script src="../scripts/media/js/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript" src="../scripts/media/js/complete.js"></script>
<script type="text/javascript" src="../scripts/media/jsjquery.dataTables.js"></script>
<script type="text/javascript" src="../scripts/media/js/jquery.dataTables.columnFilter.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#example').dataTable();
} );
</script>

<div>
<h1>Employees</h1>

<table width="100%">
<tr>
<td>
<div class="scrollbar">
<table id="example" border="0" cellspacing="2" cellpadding="2" width = "100%">
<thead>
<tr>
<th scope="col">Reg</th>
<th scope="col">Title</th>
<th scope="col">Availability</th>
<th scope="col">Latitude</th>
<th scope="col">Longitude</th>
<th scope="col">Average Speed (km/h)</th>
</tr>
</thead>
<tbody>
<?php foreach ($result2 as $row):?>
<tr class="alternate">
<td><?php echo $row['resReg']; ?></td>
<td><?php echo $row['resTitle']; ?></td>
<td><?php echo $row['resAvailability'] ? 'Yes' : 'No';?></td>
<td><?php echo $row['resLatitude']; ?></td>
<td><?php echo $row['resLongitude']; ?></td>
<td><?php echo $row['resAvgSpeed']; ?></td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
</td>
</tr>
</table>
</div>

最佳答案

您缺少 css 文件。添加它,您的问题应该得到解决。

关于php - jQuery DataTable 创建问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10690608/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com