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 Build a Simple PHP Application Listing Inventory Items Understanding Whitespace

Avery Freeman-wheaton
Avery Freeman-wheaton
2,273 Points

Two shirts but four columns per row - shirts for mike php exercise

Hi,

I'm getting two shirt pictures but four columns per row (two rows) for the 'Shirts for Mike' shirts.php exercise.

Has anyone encountered this?

I downloaded the example and followed it as closely as possible. I opened the example and it displayed correctly, so it's not my browser ... I am really not sure what I did wrong.

Here's what it looks like:

two_shirts_four_columns.png

And here's my code:

<div class="section shirts page">
    <div class="wrapper">
        <h1>Mike's Full Catalog of Shirts</h1>
        <ul class="products">
            <?php foreach($products as $product) { 
                echo "<li>";
                echo '<a href="#">';
                echo '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">';
                echo "<p>View Details</p>";
                echo "</a>";
                echo "<li>";
            } ?>
        </ul>
    </div>
</div>

Thanks!! -Avery

2 Answers

Ashley Franklin
Ashley Franklin
17,633 Points

Hey, Avery! Looks like you just need to close the list at the end there :)

Avery Freeman-wheaton
Avery Freeman-wheaton
2,273 Points

Hi Ashley,

The page references both header.php and footer.php include files, so I am pretty sure that's not the problem, but I'll give it a shot and see what happens.

Thanks! Avery

Actually, the last echo looks like it should be a close li.

I find that these problems often become obvious if I view the source from the browser. In the meantime, send us a fork snapshot if you are working in Workspaces.