From the course: PHP: Object-Oriented Programming with Databases

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Previous and next page links

Previous and next page links - PHP Tutorial

From the course: PHP: Object-Oriented Programming with Databases

Start my 1-month free trial

Previous and next page links

- [Instructor] Now that we have a working pagination class and we're able to paginate the records we get back, we need to add some links so the user can navigate from one page to another. And we're going to start by adding previous and next links. So far we have pagination, but to get the pagination to work, we have to actually change the URL from page one to page two and from page two back to page one. What we want are links that send this same URL which are here on the page for the user to click on. So right below the Bicycles table, we're going to have previous and next links. Let's go into our code on index.php and let's go down below the table, and let's add some php tags, and let's start trying to write the code that we want to go here. Now we want to have this pagination, but we don't always want to have the pagination. For example, what if we had a page that only had four bicycles on it, right? In that case, we don't need pagination. We don't have more than one page. So let's…

Contents