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

Adding Active States to the Navigation

Hi,

I'm working on the basics of php - in the stage "build a simple PHP application", I'm trying to add active states to the menu. Unfortunately, adding my php code to echo "on" so the class in enabled doesn't work correctly.

Here's my header page:

<html> <head> <title><?php echo $pageTitle; ?></title> <link rel="stylesheet" href="css/style.css" type="text/css"> <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Oswald:400,700" type="text/css"> <link rel="shortcut icon" href="favicon.ico"> </head> <body>

<div class="header">

    <div class="wrapper">

        <h1 class="branding-title"><a href="./">Shirts 4 Mike</a></h1>

        <ul class="nav">
            <li class="shirts <?php if ($section == "shirts") { echo "on";} ?>"><a href="shirts.php">Shirts</a></li>
            <li class="contact"><a href="contact.php">Contact</a></li>
            <li class="cart"><a href="#">Shopping Cart</a></li>
        </ul>

    </div>

</div>

<div id="content">

If anyone can let me know where i'm going wrong, I'd really appreciate it!

Meka

And here's my Shirts page -

Here's my "Shirts" page:

<?php $pageTitle = "Shirts"; $section = "shirts"; include('inc/header.php'); ?> <div class="section page"> <h1>Meka’s Full Catalog Of Shirts</h1> </div> <?php include('inc/footer.php'); ?>

4 Answers

Thanks for your help guys, I think it must have been a misspell somewhere I was too tired to pick up on. Everything works as it should this morning after I removed all the related php and coded it again...

As far as I can tell everything is fine. Maybe you should check if everything is spelled correctly.

Can you show everything you have on header.php.

have you created a CSS rule that selects the "on" class?

.on {
    border-bottom: solid;
}

It comes in the project files.