Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Enhancing a Simple PHP Application Paginating a List: Model and View Introducing While Loops

What if i have 2000 pages for while loop?

How do i only show the previous 4, curtain page, and the next 5. Also giving a option to go to the next set of pages?

2 Answers

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Susan;

In addition to Kevin's suggestions, there is a reasonably decent tutorial on pagination in PHP here. It is at least worth reading to get an idea of some of what is involved in pagination outside of a CMS or framework.

Happy coding,

Ken

Kevin Korte
Kevin Korte
28,149 Points

What you want is called pagination. It's also probably more involved that a forum answer can provide.

If you haven't yet, you should check out this treehouse lesson http://teamtreehouse.com/library/enhancing-a-simple-php-application-2

In particular, you should watch the last two sections called Paginating a List: Controller and Paginating a List: Model and View.

If you're using a CMS, most of them will already have built in pagination functions that are very quick and easy to use.