Posted By

davidsword on 09/20/08


Tagged

page highlight current


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

mrjthethird


Highlight current page in navigation


 / Published in: PHP
 

URL: http://davidsword.ca/

  1. <?php
  2. //page titles / page number
  3. $titles = array(
  4. 'Page Number 1' => '01',
  5. 'Page Number 2' => '02',
  6. 'Page Number 3' => '03'
  7. );
  8. //get current page
  9. $page = (!empty($_GET['page'])) ? $_GET['page'] : null;
  10. //write pages
  11. foreach($titles as $v => $k) {
  12. $h = ($k == $page) ? " style='background:yellow;'" : '';
  13. echo "<a href='?page=$k'$h>$v</a><br />\n";
  14. }
  15.  
  16. // If page is '?page=02', will print...
  17. //
  18. // <a href='?page=01'>Page Number 1</a>
  19. // <a href='?page=02' style='background:yellow;'>Page Number 2</a>
  20. // <a href='?page=03'>Page Number 3</a>
  21. ?>

Report this snippet  

You need to login to post a comment.