/ Published in: PHP

What this does is takes the name of your document using the basename function. And then you echo out the current id (id="current") if this page is present. Then using CSS we can give the current id an active color.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<div id="nav"> <ul> <li><a href="index.php"<?php if($currentPage == 'index.php') { echo 'id="current"'; } ?>>home</a></li> <li><a href="about.php" <?php if($currentPage == 'about.php') { echo 'id="current"' ;} ?>>About us</a></li> <li><a href="portfolio.php" <?php if($currentPage == 'portfolio.php') { echo 'id="current"'; } ?>>Portfolio</a></li> <li><a href="contact.php" <?php if($currentPage == 'contact.php') { echo 'id="current"'; } ?>>contact</a></li> </ul> </div><!-- END nav -->
Comments
