I am paginating a ton of records.
But my pagination script only makes a link on the page that allows me to go to the next page of results. I want to put that list inside of a dropdown menu.
Here's my code:
<table>
<?
// START PAGINATION SCRIPTING
if(!isset($_GET['page'])){ // If current page number, use it
$page = 1;
} else { // if not, set one!
$page = $_GET['page'];
}
$max_results = 20; // Define the number of results per page
$from = (($page * $max_results) - $max_results); // Figure out the limit for the query based on the current page number.
// END PAGINATION SCRIPTING
$sql = mysql_query("SELECT * FROM members LIMIT $from, $max_results"); // Perform MySQL query on only the current page number's results
while ($row = mysql_fetch_array($sql)) { // used when we don't need to number the list.
$row_color = ($row_count % 2) ? $color1 : $color2;
?>
<tr>
<td><?php echo $row['members_lastname']; ?></td>
</tr>
<? $row_count++; } ?>
</table>
<?
// START PAGINATION SCRIPTING - this filters specified rows of x , $max_results is the variable for changing the page number value.
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM members"),0); // Figure out the total number of results in DB:
$total_pages = ceil($total_results / $max_results); // Figure out the total number of pages. Always round up using ceil()
echo "<br><center><span class='FormValueBold'>Select a Page</span><br />"; // Build Page Number Hyperlinks
// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<Previous</a> ";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "<span class='SmallHeader'>$i</span> ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> ";
}
}
// Build Next Link
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next\">Next>></a><br><br>";
}
echo "</center>";
Any clues on how to place the last lines inside a dropdown?