【发布时间】:2013-12-20 09:51:54
【问题描述】:
我想使用 while 循环创建分页。 我已经将数据限制显示为 10。但我不知道如何在下面的时间计算中显示分页数。 有什么解决办法吗? 谢谢。
<table border=0 width=800 cellspacing=1 cellpadding=2>
<tr height=22>
<td align=center bgColor=red width=5%>No.</td>
<td align=center bgColor=red width=15%>Date</td>
<td align=center bgColor=red width=20%>Time</td>
<td align=center bgColor=red width=15%>Status</td>
</tr>
<?php
$start_hour = "05";
$start_min = "00";
$end_hour = "15";
$end_min = "00";
$start = new DateTime("$start_hour$start_min");
$end = new DateTime("$end_hour$end_min");
$article_num = 1;
$resultPerPage = 10;
$pageNum = 1;
while (($start < $end) && ($article_num <= $resultPerPage)) {
$start_time = $start->format('H:i');
$key_time = $start->format('Hi');
$start->modify('+10 minute');
$end_time = $start->format('H:i');
$link_reserv = "#";
echo ("<tr>");
echo ("<td align=center>$article_num</td>");
echo ("<td align=center>2013/12/16</td>");
echo ("<td align=center>$start_time - $end_time</td>");
echo ("<td align=center><input type=button value=Book Now onclick=\"window.location.href='$link_reserv';\"></td>");
echo ("</tr>");
$article_num++;
}
?>
</table>
【问题讨论】:
-
提示:
pages = floor(total / recordsPerPage). -
只获取total_num_rows并除以页面中要显示的记录数
-
我已经从这个
while (($start < $end)) ...中获得了页数,我删除了($article_num <= $resultPerPage),并且我成功获得了页数。一个问题是。如何限制while循环?
标签: php html while-loop pagination