我正在使用数据表jquery plugin
来显示表格。该网站使用php
构建。我有一个访客页面(guests.php
)来显示一个表格。当我运行网站时,排序和搜索功能消失,所有数据都显示在同一页面上。
我尝试将文件名更改为(guests.html
)它运行正常。
但我需要在php文件上运行它。
显示数据的代码如下:
<?php
$query="SELECT * FROM guests ORDER BY gue_id DESC";
$result= mysqli_query($con, $query);
$s = 1;
if(mysqli_affected_rows($con)!=0)
{
while ($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
echo "<tr>";
echo "<td class='a-center'>
<input type='checkbox' class='tableflat'>
</td>";
echo "<td>" .$row['gue_name']. "</td>";
echo "<td>" .$row['gue_mail']. "</td>";
echo "<td>" .$row['gue_mob']. "</td>";
echo "<td>" .$row['ev_name']. "</td>";
echo "<td>" .$row['gue_ticket_no']. "</td>";
echo "<td>" .$row['gue_rsvp']. "</td>";
echo "<td class='last'>
<a href='#' class='btn btn-info btn-xs'><i class='fa fa-pencil'></i> Edit </a>
<a href='#' class='btn btn-danger btn-xs'><i class='fa fa-trash-o'></i> Delete </a></td>";
echo "</tr>";
$s++;
}
}
?>
js脚本如下
<script src="../assets/js/datatables/js/jquery.dataTables.js"></script>
<script src="../assets/js/datatables/tools/js/dataTables.tableTools.js"></script>
<script>
$(document).ready(function () {
$('input.tableflat').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass: 'iradio_flat-green'
});
});
var asInitVals = new Array();
$(document).ready(function () {
var oTable = $('#example').dataTable({
"oLanguage": {
"sSearch": "Search all columns:"
},
"aoColumnDefs": [
{
'bSortable': false,
'aTargets': [0]
} //disables sorting for column one
],
'iDisplayLength': 12,
"sPaginationType": "full_numbers",
"dom": 'T<"clear">lfrtip',
"tableTools": {
"sSwfPath": "<?php echo base_url('assets2/js/Datatables/tools/swf/copy_csv_xls_pdf.swf'); ?>"
}
});
$("tfoot input").keyup(function () {
/* Filter on the column based on the index of this element's parent <th> */
oTable.fnFilter(this.value, $("tfoot th").index($(this).parent()));
});
$("tfoot input").each(function (i) {
asInitVals[i] = this.value;
});
$("tfoot input").focus(function () {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("tfoot input").blur(function (i) {
if (this.value == "") {
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
});
});
</script>
任何建议可能是什么问题。