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


Andrew Merrick
Andrew Merrick
20,151 Points

Adding HTML Markup

Randy or any other moderator:

I'm currently on the Adding HTML Markup video in the Paginating a List: Model and View section of the PHP course: http://teamtreehouse.com/library/programming/enhancing-a-simple-php-application/paginating-a-list-model-and-view/adding-html-markup.

I've set up the while function on the shirts.php file so that only 8 shirts are displayed on each page and there are button links to navigate the pages. However, with my code, I can see the links but the shirts are missing! I checked the CSS file and pagination is there. I don't know what is wrong since I've triple-checked that my code is the same as in the video. Since this is a long post I will submit my code in a new post.

Any help would be appreciated! Thanks!

Andrew Merrick
Andrew Merrick
20,151 Points


    require_once(ROOT_PATH . "inc/products.php");

    $current_page = $_GET["pg"];

    if (empty($_GET["pg"])) {
        $current_page = 1;
    } else {
        $current_page = $_GET["pg"];
    $current_page = intval($current_page);

    $total_products = get_products_count();
    $products_per_page = 8;
    $total_pages = ceil($total_products / $products_per_page);

    if ($current_page > $total_pages) {
        header("Location: ./?pg=" . $total_pages);

    if ($current_page < 1) {
        header("Location: ./");

    $start = (($current_page - 1) * $products_per_page) + 1;
    $end = $current_page * $products_per_page;
    if ($end > $total_products) {
        $end = $total_products;

    // $products = get_products_subset($start,$end);

$pageTitle = "Mike's Full Catalog of Shirts";
$section = "shirts";
include(ROOT_PATH . 'inc/header.php'); ?>

        <div class="section shirts page">

            <div class="wrapper">

                <h1>Mike&rsquo;s Full Catalog of Shirts</h1>

                <div class="pagination">

                    <?php $i = 0; ?>
                    <?php while ($i < $total_pages) : ?>
                        <?php $i += 1; ?>
                        <?php if ($i == $current_page) : ?>
                            <span><?php echo $i; ?></span>
                        <?php else : ?>
                            <a href="./?pg=<?php echo $i; ?>"><?php echo $i; ?></a>
                        <?php endif; ?>
                    <?php endwhile; ?>


                <ul class="products">
                    <?php foreach($products as $product) { 
                            echo get_list_view_html($product);



<?php include(ROOT_PATH . 'inc/footer.php') ?>

1 Answer

Andrew Merrick
Andrew Merrick
20,151 Points

Nevermind! I had a piece of code that was commented out for some reason but when I uncommented it the shirts returned.

My bad!