2016-02-23 68 views
0

我很公平的noob当涉及到PHP和只是想知道如何我可以让我的表分裂成页面,因为它有超过200,000记录在数据库中,如果有可能转到表格的下一个/上一个页面而不刷新网页?移动到php桌面的下一个页面没有刷新

这是我的表,任何建议非常感谢!

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

+0

检出数据表插件并使用其服务器端分页。 https://www.datatables.net/ – WillardSolutions

+0

看看这个ajax分页(http://www.sitepoint.com/pagination-jquery-ajax-php/) –

+0

Datatables或类似的jsvascript插件肯定...与json饲料并为这么多的数据启用服务器端处理选项 – charlietfl

回答

0

添加一个类你的细胞:

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>"; 
?> 

,并在客户端使用JavaScript,jQuery的还是要隐藏或显示他们什么......

有插件可以为你做前面评论... 这不是最好的答案,但我希望它可以帮助你。