php - 使用 jquery 显示表中的特定行
问题描述
我正在尝试显示一个有 100 行的表格,我想首先显示前 20 行并隐藏其他行……然后接下来的 20 行直到我们达到 100 行……我是使用 jQuery 的新手,所以我不不知道该怎么做我试过这样的东西,但它肯定是错的
PHP
<?php
$sql = "SELECT *, ROW_NUMBER() OVER(ORDER BY jloc_title ASC) AS Rownum,jloc_id, jloc_title
FROM Locations";
$stmt = sqlsrv_query($connection,$sql);
if($stmt == false)
{
echo"Error (sqlsrv_query):".print_r(sqlsrv_errors(),true);
exit;
}
while($row1=sqlsrv_fetch_array($stmt))
{
$id = $row1[0];
$title = $row1[1];
$Rownumber = $row1[2];
echo"<tr id='Row' value='".$Rownumber."' >";
echo"<td class='text-center'> " .$Rownumber. "</td>";
echo"<td class='text-center'> " .$id. "</td>";
echo"<td class='text-center'> " .$title. "</td>";
echo"</tr>";
}
?>
jQuery
$(document).ready(function(){
var number = document.getElementById("table1").rows.length ;
var counter= 0 ;
for (i=0; i<=number; i+=20) {
if (counter == 0) {
if (number > 20) {
var $rows = $("#table1 tr");
$rows.eq(21).hide();
...
$rows.eq(100).hide();
}
counter++;
}
else if (counter == 1) {
while (counter == 1 ) {
if (number > 40 ) {
var $rows = $("#table1 tr");
$rows.eq(0).hide();
...
$rows.eq(21).hide();
$rows.eq(60).hide();
...
$rows.eq(100).hide();
}
counter++;
}
} else {
...
}
setInterval(function(){location.reload();}, 1000*10);
}
});
解决方案
推荐阅读
- vue.js - vuetify数据表组为什么会多次显示同一个组?
- keycloak - 您可以要求 Keycloak 发送电子邮件验证电子邮件吗?
- swift - Swift/CoreData:-[:]:发送到实例的无法识别的选择器
- javascript - 使用 fetch 函数会产生速记错误
- python - 最小二乘回归以拟合具有约束中心点的圆
- javascript - has many through - Sequlize association through a association
- elasticsearch - 大索引中单个字段的 Elasticsearch 精确子字符串匹配
- animate.css - 如何在 zoomchart 中添加 animate.css 类?
- jmeter - GUI 模式和非 GUI 模式之间平均响应时间的 Jmeter 差异
- java - 我的选项中打印出所有 3 个条件