Jump to content
Larry Ullman's Book Forums

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.

Share this post

Link to post
Share on other sites

Probably because it's not created within an LI. I'd define the current page as an LI (without any link) and see if that does it.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...