Jump to content

[SOLVED] PHP to find out which page is active


bruckerrlb

Recommended Posts

Hello, I am trying to use php to find out which page is active on my website. I've figured out the logic part, but am having problem with the syntax and getting it to work, here is an example of what I"m doing:



<div id="menu">
            <ul>
            		
                 <li<?php echo ($navsection == 'home') ? ' class="act";' : "; ?>><a href="index.html">home</a></li>
                 <li<?php echo ($navsection == 'company') ? ' class="act";' : "; ?>><a href="company.html">home</a></li>
                 <li<?php echo ($navsection == 'services') ? ' class="act";' : "; ?>><a href="services.html">home</a></li>
                <li<?php echo ($navsection == 'contact') ? ' class="act";' : "; ?>><a href=contact.html">home</a></li>
            </ul>


 

And then from there, each page gets this at the very top

<?php
$navsection = 'home';
?>

 

I'm getting an error that says Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\template003\site\includes\toolbar.php on line 11 Basically my question is how can I write this line correctly

<li<?php echo ($navsection == 'home') ? ' class="act";' : "; ?>

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.