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

Ray Knag
Ray Knag
8,110 Points

Adding Pagination Links PHP

Trying to figure out why the page displays Pages: 1 2pg=2'>2 3 4 5 when attempting pagination instructions from the video, I am pretty sure that I copied the code correctly and it works, but does not display as expected, I have:

<div class="pagination"> Pages: <?php

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

I think I have narrowed down the issue to a possible syntax error with echo "pg=$i'>$i</a>";

but cant seem to figure out how to correct this without breaking the site with additional syntax errors.

Thank you for the help!

Ray Knag
Ray Knag
8,110 Points

Nevermind! I close a } too early after the echo statement... whoops!

1 Answer

This line doesn't look right either...

echo "pg=$i'>$i</a>";