Jump to content
Larry Ullman's Book Forums

Bootstrap Pagination


Recommended Posts

// Make the links to other pages, if necessary.
if ($pages > 1) {
	
	echo '<ul class="pagination" style="margin-top: -45.0px;">';
	$current_page = ($start/$display) + 1;
	
	// If it's not the first page, make a Previous button:
	if ($current_page != 1) {
		echo '<li><a href="view_users.php?s=' . ($start - $display) . '&p=' . $pages . '&sort=' . $sort . '" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
	}
	
	// Make all the numbered pages:
	for ($i = 1; $i <= $pages; $i++) {
		if ($i != $current_page) {
			echo '<li><a href="view_users.php?s=' . (($display * ($i - 1))) . '&p=' . $pages . '&sort=' . $sort . '"><span class="sr-only">' . $i . '</span></a></li>';
		} else {
			echo $i . ' ';
		}
	} // End of FOR loop.
	
	// If it's not the last page, make a Next button:
	if ($current_page != $pages) {
		echo '<li><a href="view_users.php?s=' . ($start + $display) . '&p=' . $pages . '&sort=' . $sort . '" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
	}
	
	echo '</ul>'; // Close the paragraph.
	
} // End of links section.

I have added pagination (code above) as per "PHP and MySQL for Dynamic Websites (4th Edition)" to the first website (Selling Virtual Goods).  The Boostrap pagination displays correct with the exception of the active page displaying outside of the Boostrap pagination.  Am I missing something obvious? I did search the web but could not find a solution.  Any help will be much appreciated.

Link to comment
Share on other sites

 Share

×
×
  • Create New...