我有一个表从数据库中获取数据
我想为桌子做分页但不刷新页面
我的表格代码:
<?php
<table id="table2" class="table table-hover table-mc-light-blue ">
<thead>
<tr>
<th>#</th>
<th>اسم المطرب</th>
<th>عدد الاغاني</th>
<th>تعديل</th>
</tr>
</thead>
<tbody class="searchable" >
<?php
$artistquery= mysqli_query($conn,"SELECT * FROM `artist` ORDER BY `artistID` DESC ");
$num=1;
$x=0;
while($listartist = mysqli_fetch_assoc($artistquery)){
$songquery= mysqli_query($conn,"SELECT * FROM `songs` WHERE `artist` = '$listartist[artistname]' ");
$songsnumber = mysqli_num_rows($songquery);
$x+=0.1;
echo'
<tr class="animated bounceIn " style=" animation-delay:'.$x.'s;">
<td data-title="#"></td>
<td data-title="اسم المطرب"></td>
<td data-title="عدد الاغاني"></td>
<td data-title=""></td>
</tr> ';}
?>
注意:我试过DataTables.js,但我确实知道如何删除过滤器并显示标签。 有什么不同的方法吗?
答案 0 :(得分:0)
我不完全理解你的查询,所以我会坚持分页。假设您希望一次显示10个项目,并且使用next
和prev
作为分页按钮,您可以在查询中使用LIMIT 10
或使用{{1}渲染第一个视图}}。我有这个下载的包含拉链(国家和代码)的json文件,这是我用来测试它的。下一个和上一个完全完美,但它的工作原理。
array_slice($mysql_result,0,10)