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 > Including the Product Arrays Stage (Stage 5)

When I hit CMD+R after updating per Randy's instruction at 4:49 in the video for the shirts.php file, I do not see the product key showing up after local host in the URL bar.

Here is my code:

a) shirt.php

<?php include("inc/products.php"); ?>

b) shirts.php:

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

    <div class="section shirts page">

        <div class="wrapper">

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

                <ul class = "products">
                 <?php foreach ($products as $product) {
                    echo "<li>";
                    echo '<a href="shirt.php">';
                    echo '<img src="' . $product["img"] . '"alt="' . $product[$name] . '">';
                    echo "<p>View Details</p>";
                    echo "</a>";  
                    echo "</li>";  
                    }
                 ?>

                </ul>

        </div>

    </div>

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

c) products.php:

<?php

$products = array();

$products[101] = array(
    "name" => "Logo Shirt, Red",
    "img" => "img/shirts/shirt-101.jpg",
    "price" => 18,
    "paypal" => "9P7DLECFD4LKE"
);
$products[102] = array(
    "name" => "Mike the Frog Shirt, Black",
    "img" => "img/shirts/shirt-102.jpg",
    "price" => 20,
    "paypal" => "SXKPTHN2EES3J"
);
$products[103] = array(
    "name" => "Mike the Frog Shirt, Blue",
    "img" => "img/shirts/shirt-103.jpg",    
    "price" => 20,
    "paypal" => "7T8LK5WXT5Q9J"
);
$products[104] = array(
    "name" => "Logo Shirt, Green",
    "img" => "img/shirts/shirt-104.jpg",    
    "price" => 18,
    "paypal" => "YKVL5F87E8PCS"
);
$products[105] = array(
    "name" => "Mike the Frog Shirt, Yellow",
    "img" => "img/shirts/shirt-105.jpg",    
    "price" => 25,
    "paypal" => "4CLP2SCVYM288"
);
$products[106] = array(
    "name" => "Logo Shirt, Gray",
    "img" => "img/shirts/shirt-106.jpg",    
    "price" => 20,
    "paypal" => "TNAZ2RGYYJ396"
);
$products[107] = array(
    "name" => "Logo Shirt, Teal",
    "img" => "img/shirts/shirt-107.jpg",    
    "price" => 20,
    "paypal" => "S5FMPJN6Y2C32"
);
$products[108] = array(
    "name" => "Mike the Frog Shirt, Orange",
    "img" => "img/shirts/shirt-108.jpg",    
    "price" => 25,
    "paypal" => "JMFK7P7VEHS44"

);

?>

1 Answer

Another thought I am having as to why the code is not running properly is the location of where I saved my files. Is there any easy way to attach a screenshot?