Simple PHP Navigation

/ Published in: PHP
Save to your folder(s)

Very simple navigation. Style the id using CSS. Allows you to highlight the current page with CSS.

Copy this code and paste it in your HTML
  1. //Place this in an include
  2. <ul>
  3. <li><a href="../index.php" <?php if($thisPage == 'home') echo 'id="here"';?> >Home</a></li>
  4. <li><a href="../page1/index.php" <?php if($thisPage == 'page1') echo 'id="here"';?> >Page 1</a></li>
  5. <li><a href="../page2/index.php" <?php if($thisPage == 'page2') echo 'id="here"';?> >Page 2</a></li>
  6. <li><a href="../page3/index.php" <?php if($thisPage == 'page3') echo 'id="here"';?> >Page 3</a></li>
  7. </ul>
  9. //This php goes inside each page, notice the variable
  10. <?php
  11. $thisPage = 'home';
  12. include('includes/');
  13. ?>


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.