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

Flo Tubes
Flo Tubes
5,110 Points

Displays too many items

I the video it displays 4 items horizontally. On my screen displays way more items verticaly.

This is my catalog.php:

<?php 
include("include/data.php");






$pageTitle = "Full Catalog";
$section = null;

if(isset($_GET["cat"])){

  if($_GET["cat"]== "books"){
      $pageTitle = "Books";
    $section = "books";
  }
     else if($_GET["cat"]== "movies"){
       $pageTitle = "Movies";
       $section = "movies";
  }
    else if($_GET["cat"] == "music"){
      $pageTitle= "Music";
      $section = "music";
  }
}
include("include/header.php");

?>

<div class="section catalog page">
  <div class="wrapper">

      <h1><?php echo $pageTitle;?></h1>

    <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>

  </div>




</div>
<?php include("include/footer.php");?>

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

[edited OP for formatting -- to include a code block you should rap your code with 3 backticks (```) on the line before and after as shown in the Markdown cheatsheet.]

In this line you have a semi-colon in the middle of the output you are trying to build. This will end the echo statement and cut off anything after it. This includes the closure of the image tag and closing tags of the anchors and list items.

          .$item["title"];"'/>"
Flo Tubes
Flo Tubes
5,110 Points

It displays them properly now but still too many but I think I can fix that somehow

Prince Henry
Prince Henry
4,312 Points

perhaps you should look into your <ul> class and try using <ul class="items">