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

Extra Credit - Paginating a List: Shirts will not display correctly

After completing the final stage of "Enhacing a Simple PHP Application" where you create the pagination, I decided to try the extra credit assignment and put the code for the product list view into a separate include file. After much wailing and gnashing of teeth, I finally got it to display. Problem is there is only three on each line. This is happening on both the home page and the shirts page. The last time this issue occured it was due to extra white space, bit I can't seem to find any piece of code which is causing the problem. I literally tried copying and pasting from the project files with no success.

Here is the include file:

<li>
    <a href='<?php echo BASE_URL; ?>shirts/<?php echo`$product["sku"]; ?>/'>
      <img src="<?php echo BASE_URL . $product["img"]; ?>" alt="<?php`echo $product["name"]; ?>">
      <p>View Details</p>
    </a>
</li>

Here is the code from the shirts listing page where the file is included:

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

        <div class="section shirts page">

            <div class="wrapper">

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

        <?php include(ROOT_PATH . "includes/partial-list-navigation.html.php"); ?>

                <ul class="products">
                    <?php 
            foreach($products as $product) {
                            include(ROOT_PATH . "includes/partial-list-view.html.php");                 
            }      
          ?>
                </ul>

        <?php include(ROOT_PATH . "includes/partial-list-navigation.html.php"); ?>

            </div>

        </div>

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

And this is from the home page:

        <div class="section banner">

            <div class="wrapper">

                <img class="hero" src="img/mike-the-frog.png" alt="Mike the Frog says:">
                <div class="button">
                    <a href="shirts.php">
                        <h2>Hey, I&rsquo;m Mike!</h2>
                        <p>Check Out My Shirts</p>
                    </a>
                </div>
            </div>

        </div>

        <div class="section shirts latest">

            <div class="wrapper">

                <h2>Mike&rsquo;s Latest Shirts</h2>

                <ul class="products">
                    <?php
                        foreach(array_reverse($recent) as $product) {
                            include(ROOT_PATH . "includes/partial-list-view.html.php");
                        }
                    ?>              
                </ul>

            </div>

        </div>

    </div>

Lastly here is the link to the CSS: http://codepen.io/LibraryIT/pen/jlGmD.css I have not touched it all since downloading the project files.

Any help would be much appreciated

3 Answers

I played around with the padding for the list items containing the shirts (under .section.shirts ul.products li in the CSS file). Chopping off four pixels did the trick.

Could you please post your HTML and CSS codes. If they are too big use Codepen ( http://www.codepen.io/ )

The include file is literally all you see above. I posted the CSS, but did not alter it in anyway since downloading it and would be very surprised to find that that was an issue. Also I expanded the selection from the Home page and shirts listing pages. The only thing I did not post was the controller code from the shirts listing page. But since that has nothing to do with display I doubt there is an issue there. It feels like there's a problem with the HTML in the include file, but I can't spot anything.