Jump to content

using php to add id to an element based on current page


amplexus

Recommended Posts

Hi again,

 

I've got a php include for a Navigation list, and I'm trying to get it to add the id tag to the current page.  my code looks like this:

 

<a href="order.php"<?php  if ($currentpage == 'order.php') {echo 'id="here"';} ?>>Order Lobsters</a>
    |<a href="about.php"<?php if ($currentpage == 'about.php') {echo 'id="here"';} ?>>About Us</a>
    |<a href="crew.php"<?php if ($currentpage == 'crew.php') {echo 'id="here"';} ?>>Our Crew</a>
    |<a href="rental.php"<?php if ($currentpage == 'rental.php') {echo 'id="here"';} ?>>Rental Property</a>
    |<a href="contact.php"<?php if ($currentpage == 'contact.php') {echo 'id="here"';} ?>>Contact Us</a>
    |<a href="facility.php"<?php if ($currentpage == 'facility.php') {echo 'id="here"';} ?>>Our Green Facility</a>

 

I'm not getting any errors, just not working.  if I remove the "if" statement, the echo works, so I know my problem is there.  maybe I have the wrong syntax for the page name string?  where is it looking to get that information?  I've only tested on my local xampp server, but these are relative links, no?

 

thanksi n advance for your help.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.