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 Integrating PHP with Databases Limiting Records in SQL Calculations and Links

James Fisher
James Fisher
29,163 Points

From the transcript/video: If we're on a category page, then we wanna redirect them to a category page.

Can you explain the logic?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, James Fisher! Yes, this sounds a little unclear. Why would we want to redirect them to the place we already are, right? :smiley: In this case, we're doing pagination. In the general page everything is all clumped together. Books are displayed with movies etc. But when we move to a category page we're sending in the category. The intention here, I believe, is to say that if we're in a page that's limited to a category, we want to redirect them back to the same category we're in.

Imagine this scenario: you have a page of books and a page of movies. Both "books" and "movies" are categories and each "page" of the pagination contains 5 titles. On the first "page" are the first 5 titles. But imagine you clicked the "2" link to take you to the next page of books and instead, it hopped over to show the matches 6-10 of of the movies category. That would be bizarre behavior. Or, even worse, it took you to the second page of all items.

The idea here is that in the case the category is set, we are redirecting back to the same category.

Hope this helps! :sparkles:

James Fisher
James Fisher
29,163 Points

Thanks Jennifer, I appreciate you taking the time to clear that up! That seems perfectly logical - though sometimes it seems in this course the instructor doesn't always take the time to imprint the logic that needs to be driven into a new student's thought process when learning the "why" behind the code...