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 Creating the Display Function

Css is weird both places now..

So now the css where the books/music/movies are is weird both places now, so i tried to download the Project Files but it didn't help at all. Here's my code for index.php:

index.php
<?php 
include("inc/data.php");
include("inc/functions.php");

$pageTitle = "Personal Media Library";
$section = null;

include("inc/header.php"); ?>
        <div class="section catalog random">

            <div class="wrapper">

                <h2>May we suggest something?</h2>

        <ul class="catalog">
            <?php
            foreach ($catalog as $id=>$item) {
                echo get_item_html($id,$item);
            }
            ?>                              
                </ul>

            </div>

        </div>

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

and catalog.php:

catalog.php
<?php 
include("inc/data.php");
include("inc/functions.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("inc/header.php"); ?>

<div class="section catalog page">

    <div class="wrapper">

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

        <ul>
            <?php
            foreach ($catalog as $id=>$item) {
                echo get_item_html($id,$item);
            }
            ?>
        </ul>

    </div>
</div>

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

2 Answers

Hi Mike,

The css file you have is probably expecting the ul class to be "items". This is the class that is shown in the previous video for the catalog page.

<ul class="items">

Make sure you have this on both your index page and catalog page. Post back if that didn't solve the styling issues.

Ben Os
Ben Os
20,008 Points

I have this class in the ul tags in both index.php and catalog.php but my items look like a long html list and there is no css in the site...

No errors...

Hi Ben,

If you're doing this in workspaces can you post a snapshot?

No css is being applied to any part of the site?

Hi jason,

That did work thank you so much! :)