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

pgages go to page 2 and 3 but none of the items change.

I followed the video step by step, and tried the example code but the Pages change in the url, ?pg=1, ?pg=2, ?pg=3.....etc but the items inside the full catalog they stay the same 8 from the 1st page. I really am getting confused any help ro guidance would be appreciated!

$pagination = "<div class=\"pagination\">";
$pagination .= 'Pages: ';
for($i = 1; $i < $total_pages; $i++) {
    if ($i == $current_page) {
        $pagination .= " <span>$i</span>";
    } else {
        $pagination .= " <a href='catalog.php?";
     if (!empty($section)) {
            $pagination .= "cat=".$section."&";
        }
        $pagination .= "pg=$i'>$i<a>";
    }
}
$pagination .= "</div>";

1 Answer

Niki Molnar
Niki Molnar
25,698 Points

Hi Michael

The code you've shown loops through the pagination to show what pages are available.

Do you have the code for getting the page number from the querystring and getting the list using that page?

Niki