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 trialRoss Campbell
5,410 Pointsno longer showing images
hello everyone!
hoping for a little bit of insight, before i tear my code apart. So far everything has been spot on while building the T-shirt store, but i've just got to building the shirt display function and now all the images have gone. The box and border shows up as does the view details with the orange x on hover, but i've lot the shirt images.
i've looked through the code you write in this video and can't find an discrepancies.
function get_list_view_html($products_id, $products) {
// build HTML output;
$output = "";
$output = $output . "<li>";
$output = $output . '<a href="shirt.php?id=' . $product_id . '">';
$output = $output . '<img src="' . $product["img"] . '"alt="' . $product["name"] . '">';
$output = $output . '<p>View Details</p>';
$output = $output . "</a>";
$output = $output . "</li>";
return $output;
}
any help or insight would be greatly appreciated.
thanks everyone.
Ross
4 Answers
Jason Anello
Courses Plus Student 94,610 PointsHi Ross,
You've added 's' to your function parameters.
function get_list_view_html($products_id, $products) {
should be:
function get_list_view_html($product_id, $product) {
Aimee Burnett
4,130 PointsI am having nearly the same issue. I have read this question forum and even copied the amended version of the code shown here to try and remedy the white screen popping up on my shirts.php (it is a completely blank screen), and no images showing on the index.html (the header and footer show up here but the images do not). I have looked through the code and watched the video three times to try and see what small errors I am making in the files to cause this but I can't find them.
The following is my shirts.php code in full:
include("inc/products.php");
$pageTitle = "Mike's Full Catelog of Shirts";
$section = "Shirts";
include('inc/header.php'); ?>
<div class="section shirts page">
<div class="wrapper">
<h1>Mike’s Full Catelog of Shirts</h1>
<ul class="products">
<?php foreach($products as $product_id => $product) {
echo get_list_view_html($product_id,$product);
}
?>
</ul>
</div>
</div>
<?php include('inc/footer.php'); ?>
and my inc/products.php code is shown below:
<?php
function get_list_view_html($product_id, $product) {
$output = "";
$output = $output . "<li>";
$output = $output . '<a href="shirt.php?id=' . $product_id . '">';
$output = $output . '<img src="' . $product["img"] . '" alt="' . $product["name"] . '">';
$output = $output . "<p>View Details</p>";
$output = $output . "</a>";
$output = $output . "</li>";
return $output;
}
Any help anyone could offer would be awesome. Just can't seem to comb through it and find the solution. I think I may just need a second set of eyes.
Jason Anello
Courses Plus Student 94,610 PointsHi Aimee,
In shirts.php I don't see your opening php tag at the top. Was that a copy/paste error or is it missing from your code?
For the index page, is it currently using the get_list_view_html
function?
Aimee Burnett
4,130 PointsHey jason, yeah there are php tags in my code it just cut off the code at the top when I included them for some reason so I left them out. Sorry I realize that is a bit confusing. So I suppose read the code as though the php tags are implemented correctly
Michael Lazarz
15,135 PointsI had the same issue and this is what I found to be the problem. Look at your products.php file. Then look at the $products [101] = array and look at the "sizes" => array. Make sure that you include the enclosing " ) " but not a semi-colon but then make sure the closing " ) " for the entire array does have one at the end. So:
(``` $products[101] = array( "name" => "Logo Shirt, Red", "img" => "img/shirts/shirt-101.jpg", "price" => 18, "paypal" => "9P7DLECFD4LKE", "sizes" => array("Small", "Medium", "Large", "X-Large") <------------------------ ( This is needed to close the "sizes" array ) ); <--------( this is needed to close out entire array)
That was the issue I had. Not sure if that helps at all. And I apologize if the code is messy. For some reason it wouldn't let me format the right way.