Php 如何在接下来的所有页面中使用分页继续编号列表?
我试图在php中以分页的方式显示有序列表中的数据。它在第一页运行良好,但在下一页,列表从1开始,而不是从上一个数字继续 这是我的密码:Php 如何在接下来的所有页面中使用分页继续编号列表?,php,page-numbering,Php,Page Numbering,我试图在php中以分页的方式显示有序列表中的数据。它在第一页运行良好,但在下一页,列表从1开始,而不是从上一个数字继续 这是我的密码: <?php // find out how many rows are in the table $sql01 = mysql_query("SELECT COUNT(*) FROM pm,pm_reply"); $r = mysql_fetch_row($sql01); $numrows = $r[0]; $rowsperpage = 3; $tot
<?php
// find out how many rows are in the table
$sql01 = mysql_query("SELECT COUNT(*) FROM pm,pm_reply");
$r = mysql_fetch_row($sql01);
$numrows = $r[0];
$rowsperpage = 3;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
// default page num
$currentpage = 1;
}
// if current page is greater than total pages...
if ($currentpage > $totalpages) {
// set current page to last page
$currentpage = $totalpages;
}
// if current page is less than first page...
if ($currentpage < 1) {
// set current page to first page
$currentpage = 1;
}
// the offset of the list, based on current page
$offset = ($currentpage - 1) * $rowsperpage;
// get the info from the db
// while there are rows to be fetched...
$sql=mysql_query("select *from pm where send_to='$_GET[name]' limit $offset, $rowsperpage");
$sql2=mysql_query("select *from pm_reply where send_to='$_GET[name]' limit $offset, $rowsperpage");
echo "<ol>";
while($rows=mysql_fetch_assoc($sql)) {
echo"<li>From: <a href='profile.php?name=$rows[send_by]'>$rows[send_by]</a><br><br><a style='text-decoration:none; font-size:14pt;' href='view_pm.php?name=$_GET[name]&pm=$rows[subject]'>$rows[subject]</a></li>";
echo "<hr>";
echo "<br>";
}
while($rows2=mysql_fetch_assoc($sql2)) {
echo"<li>From: <a href='profile.php?name=$rows2[replied_by]'>$rows2[replied_by]</a><br><br><a style='text-decoration:none; font-size:14pt;' href='view_pm.php?name=$_GET[name]&pm=$rows2[subject]'>$rows2[subject]</a></li>";
echo "<hr>";
echo "<br>";
}
echo "</ol>";
echo "</div>";
//End Div Content
echo "<div style='clear:both;'></div>";
echo "<br>";
echo "<br>";
echo "<br>";
echo "<div id='pagelinks'>";
/****** build the pagination links ******/
// range of num links to show
$range = 3;
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <a href='{$_SERVER['PHP_SELF']}?name=$_GET[name]¤tpage=1'>First...</a> ";
// get previous page num
$prevpage = $currentpage - 1;
}
// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
// if it's a valid page number...
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
// if we're on current page...
// 'highlight' it but don't make a link
echo " [<b>$x</b>] ";
} else {
// if not current page...
// make it a link
echo " <a href='{$_SERVER['PHP_SELF']}?name=$_GET[name]¤tpage=$x'>$x</a> ";
}
}
}
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
echo " <a href='{$_SERVER['PHP_SELF']}?name=$_GET[name]¤tpage=$totalpages'>...Last</a> ";
}
只需将start=“$offset”
添加到您的echo'代码>行
echo "<ol start='$offset'>";
echo”“;
只需将start=“$offset”
添加到您的echo'代码>行
echo "<ol start='$offset'>";
echo”“;
只需将start=“$offset”
添加到您的echo'代码>行
echo "<ol start='$offset'>";
echo”“;
只需将start=“$offset”
添加到您的echo'代码>行
echo "<ol start='$offset'>";
echo”“;
请清理代码。清理代码和语法请清理代码。清理代码和语法请清理代码。清理代码和语法请清理代码。清理代码和语法请清理代码。清理代码和语法简短而简单的解决方案,+1.Thanx但在第一页,列表从0开始,而不是从1开始,在下一页上,它还显示上一页的最后一次计数。有解决方案吗?只需在偏移量上加1,然后<代码>$start\u from=$offset+1;回声“代码>Thanx,现在它从1开始,但在下一页,它还显示上一页的最后一个数字。现在该怎么办?简短而简单的解决方案,+1.Thanx但在第一页,列表从0开始,而不是从1开始,在下一页,它还显示上一页的最后一次计数。有解决方案吗?只需在偏移量上加1,然后<代码>$start\u from=$offset+1;回声“代码>Thanx,现在它从1开始,但在下一页,它还显示上一页的最后一个数字。现在该怎么办?简短而简单的解决方案,+1.Thanx但在第一页,列表从0开始,而不是从1开始,在下一页,它还显示上一页的最后一次计数。有解决方案吗?只需在偏移量上加1,然后<代码>$start\u from=$offset+1;回声“代码>Thanx,现在它从1开始,但在下一页,它还显示上一页的最后一个数字。现在该怎么办?简短而简单的解决方案,+1.Thanx但在第一页,列表从0开始,而不是从1开始,在下一页,它还显示上一页的最后一次计数。有解决方案吗?只需在偏移量上加1,然后<代码>$start\u from=$offset+1;回声“代码>Thanx,现在它从1开始,但在下一页,它还显示上一页的最后一个数字。现在该怎么办?