Pagination - Removing a large space between bottom of rows and pagination links
The pagination below works well. It splits a table into 25 rows per page. However, when I click on a page besides page one, there is a large space between the bottom of the 25 rows and the pagination links. I think the problem is related to the CSS. How can I get rid of this large space?
Thanks in advance,
John
/****** build the pagination links ******/
// range of num links to show
// if not on page 1, don't show back links
if ($currentpage > 1) {
// show << link to go back to page 1
echo " <div class='pages'><div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=1&find={$_SESSION['find']}&searching=yes&search=search' class='links'><<</a></div> ";
// get previous page num
$prevpage = $currentpage - 1;
// show < link to go back to 1 page
echo " <div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage&find={$_SESSION['find']}&searching=yes&search=search' class='links'><</a></div> ";
} // end if
// 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 we're on current page...
if ($x == $currentpage) {
// 'highlight' it but don't make a link
echo " <div class='pages'>[<b>$x</b>] </div>";
// if not current page...
} else {
// make it a link
echo " <div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=$x&find={$_SESSION['find']}&searching=yes&search=search' class='links'>$x</a></div> ";
} // end else
} // end if
} // end for
// if not on last page, show forward and last page links
if ($currentpage != $totalpages) {
// get next page
$nextpage = $currentpage + 1;
// echo forward link for next page
echo " <div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage&find={$_SESSION['find']}&searching=yes&search=search' class='links'>></a></div> ";
// echo forward link for lastpage
echo " <div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&find={$_SESSION['find']}&searching=yes&search=search' class='links'>>></a></div> ";
} // end if
/****** end build pagination links ******/
In case it's helpful, here is how the pagination links's generated HTML looks:
</table>
<div class='pages'><div class='pages'><a href='/booksearch.php?currentpage=1&find=best book ever&searching=yes&search=search' class='links'><<</a></div> <div class='pages'><a href='/booksearch.php?currentpage=1&find=best book ever&searching=yes&search=search' class='links'><</a></div> <div class='pages'><a href='/booksearch.php?currentpage=1&find=best book ever&searching=yes&search=search' class='links'>1</a></div> <div class='pages'>[<b>2</b>] </div> <div class='pages'><a href='/booksearch.php?currentpage=3&find=best book ever&searching=yes&search=search' class='links'>3</a></div> <div class='pages'><a href='/booksearch.php?currentpage=4&find=best book ever&searching=yes&search=search' class='links'>4</a></div> <div class='pages'><a href='/booksearch.php?currentpage=5&find=best book ever&searching=yes&search=search' class='links'>5</a></div> <div class='pages'><a href='/booksearch.php?currentpage=3&find=best book ever&searching=yes&am开发者_运维问答p;search=search' class='links'>></a></div> <div class='pages'><a href='/booksearch.php?currentpage=7&find=best book ever&searching=yes&search=search' class='links'>>></a></div>
The relevant CSS:
.pages
{
overflow: hidden;
display: block;
float: left;
margin: 4px;
margin-top: 940px;
margin-left: 10px;
font-family: Arial, Helvetica, sans-serif ;
}
a.links:link {
color: #000000; text-decoration: none;
text-align:center;
margin-left:8px;
margin-bottom:0px;
padding:2px;
font-family:Arial, Helvetica, sans-serif;
font-size: 16px;
}
a.links:visited {
color: #000000; text-decoration: none;
text-align:center;
margin-left:8px;
margin-bottom:0px;
padding:2px;
font-family:Arial, Helvetica, sans-serif;
font-size: 16px;
}
a.links:active {
color: #000000; text-decoration: none;
text-align:center;
margin-left:8px;
margin-bottom:0px;
padding:2px;
font-family:Arial, Helvetica, sans-serif;
font-size: 16px;
}
a.links:hover {
color: #000000; text-decoration: none;
background-color: #FFFF00;
text-align:center;
margin-left:8px;
margin-bottom:0px;
padding:2px;
font-family:Arial, Helvetica, sans-serif;
font-size: 16px;
}
You must change "<<<" and ">>>" to the proper html entities: "<<<" and ">>>". Your HTML is broken.
For instance, this line:
echo " <div class='pages'><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&find={$_SESSION['find']}&searching=yes&search=search' class='links'>>></a></div> ";
Should be:
echo " <div class='pages><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages&find={$_SESSION['find']}&searching=yes&search=search' class='links'>>></a></div> ";
The bad HTML is almost certainly causing the unexpected display. You can't test potential spacing issues until you have properly formed markup.
I see this in your pagination example:
<div class='pages'>
<div class='pages'><a href='/booksearch[/snip]
but I don't see in your code anywhere for a "<div class='pages'>" to be by itself??
精彩评论