简体   繁体   English

无需刷新即可移至php表的下一页

[英]Move to next page of php table without refreshing

I'm fairly noob when it comes to php and was just wondering how I can have my table split into pages as it has over 200,000 records in the database and also if it's possible to go to the next/previous page of the table without refreshing the webpage? 我对PHP相当陌生,只是想知道如何将表拆分为页面,因为它在数据库中有超过200,000条记录,而且是否有可能不刷新就转到表的下一页/上一页该网页?

Here is my table, any advise is very much appreciated!!! 这是我的桌子,任何建议都非常感谢!!!

 a<?php $query = "SELECT * FROM aliases where client_id='$userid' ORDER BY time_edit DESC"; $result = mysql_query($query); if ($result->num_rows > 0) { echo "<table border=1>"; echo "<tr align=center>"; echo "<th width=25%>Alias</th>"; echo "<th width=25%>Times Used</th>"; echo "<th width=25%>First Used</th>"; echo "<th width=25%>Last Used</th>"; echo "</tr>"; echo "<tr><td>No Results</td></tr>"; } echo "<table border=1>"; echo "<tr>"; echo "<th width=25%>Alias</th>"; echo "<th width=25%>Times Used</th>"; echo "<th width=25%>First Used</th>"; echo "<th width=25%>Last Used</th>"; echo "</tr>"; while ($row = mysql_fetch_assoc($result)) { $timesused=$row['num_used']; $alias=$row['alias']; $alias=htmlentities($alias); $firstused=$row['time_add']; $firstused = date('d MYH:i:s', $firstused); $lastused=$row['time_edit']; $lastused = date('d MYH:i:s', $lastused); echo "<tr align=center>"; echo "<td>$alias</td>"; echo "<td>$timesused</td>"; echo "<td>$firstused</td>"; echo "<td>$lastused</td>"; echo "</tr>"; } echo "</table>"; ?> 

add a class to your cells: 向您的单元格添加一个类:

a<?php
$query = "SELECT * FROM aliases where client_id='$userid' ORDER BY time_edit DESC";
$result = mysql_query($query);
if ($result->num_rows > 0) {
    echo "<table border=1>";
    echo "<tr align=center>";
    echo "<th width=25%>Alias</th>";
    echo "<th width=25%>Times Used</th>";
    echo "<th width=25%>First Used</th>";
    echo "<th width=25%>Last Used</th>";
    echo "</tr>";
    echo "<tr><td>No Results</td></tr>";
}
    echo "<table border=1>";
    echo "<tr>";
    echo "<th width=25%>Alias</th>";
    echo "<th width=25%>Times Used</th>";
    echo "<th width=25%>First Used</th>";
    echo "<th width=25%>Last Used</th>";
    echo "</tr>";
    $countRow = 0;
    $class = 1;
while ($row = mysql_fetch_assoc($result)) {
$countRow += 1;
$timesused=$row['num_used'];
$alias=$row['alias'];
$alias=htmlentities($alias);
$firstused=$row['time_add'];
$firstused = date('d M Y H:i:s', $firstused);
$lastused=$row['time_edit'];
$lastused = date('d M Y H:i:s', $lastused);
    echo "<tr align=center>";
    echo "<td class='visible".$class.">$alias</td>";
    echo "<td class='visible".$class.">$timesused</td>";
    echo "<td class='visible".$class.">$firstused</td>";
    echo "<td class='visible".$class.">$lastused</td>";
    echo "</tr>";
    if($countRow == 50){ $class += 1; $countRow = 0; }
}
    echo "</table>";
?>

and on client side use javaScript, jQuery or what you prefer to hide or show them... 并在客户端使用javaScript,jQuery或您希望隐藏或显示它们的内容...

there are plugins that do it for you as commented before... This is not the best answer but I hope it helps you. 如前所述,有插件可以为您完成此任务……这不是最佳解决方案,但希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM