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 Basic PHP Website (2018) Listing and Sorting Inventory Items Displaying All Items

All of the images are not showing up??

The columns are displaying properly but for some reason it's not pulling all of the images

<ul class = "items"> <?php foreach($catalog as $item) { echo "<li><a href='#'><img src='" . $item["img"] . "' alt='" . $item["title"] . "' />" . "<p>View Details</p>" . "</a></li>";

 }

            ?>
 </ul>

On line 1 im not getting the second image On line 2 im not getting the first image On line 3 im not getting the 1 first image either?? I checked and all the right images are located in my img folder.

(BTW) I am developing locally using mamp, I don't think that matters but yeah.

2 Answers

Hi,

The array could show which retrieves the data? :)

And maybe: "I checked and all the right images are located in my img folder." If the images are int the 'img' folder:

echo "<li><a href='#'><img src='img/" . $item["img"] . "' alt='" . $item["title"] . "' />" . "<p>View Details</p>" . "</a></li>";
john murphy
john murphy
8,058 Points

echo "<li><a href='#'><img src='" . $item["img"] . "' alt='" . $item["title"] . "' />" . "<p>View Details</p>" . "</a></li>";

Fixed. You included the /img in your code and it was reading as img/img