我使用数据表制作了一个页面。但是随着数据量的增加,加载数据的速度变慢了,所以我们尝试进行分页。但是我不知道如何在当前代码中修改它。应该如何修改?
在这个我的数据表脚本中
$(function() {
$('#datatable1').DataTable({
responsive: true,
order: [[ 1, "desc" ], [ 2, "desc"]],
language: {
searchPlaceholder: 'Search...',
sSearch: '',
lengthMenu: '_MENU_ items/page',
},
dom : 'Bfrtip',
buttons: [
'copy', 'excel', 'print'
]
});
});
在这个sql查询中
$sql = "SELECT id, DATE_FORMAT(tranDate,'%Y-%m-%d') as tranDate, tranTime, date, cmd, paymethod, amount, orgRefNo, orgTranDate FROM noti_card_data WHERE mbrNO = '1'";
in this table view code
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table id='datatable1' class = table style = 'width: 100%; font-size:12.5px; font-family:nanum; background-color:transparent;'>";
echo "<thead >";
echo "<tr>";
echo "<th>No</th>";
echo "<th>amount</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . number_format($row['amount']) . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
// Free result set
mysqli_free_result($result);
}
else{
}
}
else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
在这个视图中
如何使用分页
慕桂英4014372