Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Creating the Menu and Footer Adding Active States to the Navigation

Both shirts and contact are underlined..

okay I have followed the full instructions. But both Shirts and Contacts are underlined. I don't see it is wrong as we have told to add variable section and put it equal to shirt and contact.

In the header file we, have used if variable section is equal to Shirt and Contact then put a underline..So obviously both will be underlined.

Maybe I am not seeing it clearly, please help-

?php $pageTitle = "Mike's Shirt"; $sections = "Shirts"; include('inc/header.php'); ?>

<div class="section page">

<h1>Mike’s full catalogue of Shirts.</h1> </div> </div>

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

<?php $pageTitle = "Contact Mike"; $section = "Contact"; include('inc/header.php'); ?>

<div class="section page">

<h1>Contact</h1>

</div> </div>

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

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($sections == "Shirts"){ echo " on"; }?> "><a href="shirts.php">Shirts</a></li>
    <li class="contact <?php if($section == "Contact"){ echo " on"; }?>"><a href="contact.php">Contact</a></li>
    <li class="cart"><a href="#">Shopping Cart</a></li>
  </ul>

</div>

</div>

<div id="content">

Leslie McPhail
Leslie McPhail
14,270 Points

Hi Shantanu - One issue may be the variable, as it looks like in one area you are calling the variable $section, and in another area you have made it plural as $sections. Change the plural version to $section in both the line item php and the header php, refresh, and see if it fixes the underline issue.

2 Answers

Hi,

Just want to confirm you have this at the top of your shirts.php file:

$section = "shirts";

and this at the top of your contact.php file:

$section = "contact";

They shouldn't both be in the files. One for each and notice the singular. In your example you have $section in some instances and $sections in others.

You then have the following part in your header.php file:

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

Hope that helps.

-Rich

Alena Holligan
STAFF
Alena Holligan
Treehouse Teacher

You need to define the $section variable in your index.php file as well. Add the following line after the $pageTitle:

$section = "home";