在
php 方面,我相当菜鸟,只是想知道如何将我的表拆分为页面,因为它在数据库中有超过 200,000 条记录,以及是否可以在不刷新网页的情况下转到表的下一页/上一页?
这是我的桌子,非常感谢任何建议!!
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 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>$alias</td>";
echo "<td>$timesused</td>";
echo "<td>$firstused</td>";
echo "<td>$lastused</td>";
echo "</tr>";
}
echo "</table>";
?>
将
类添加到单元格:
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或你喜欢隐藏或显示它们的东西......
如前所述,有一些插件可以为您完成...这不是最好的答案,但我希望它对您有所帮助。