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.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.