PHP Build a Basic PHP Website 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

Szabolcs Szána
Szabolcs Szána
6,881 Points

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