PHP Navigation


PHP Code
  1.  
  2. <?php
  3. switch($a) { //$page is the url, ie ?page=xxx you can change $page to anything and it will change the URL's {
  4.  
  5. default: //default page to include
  6. include('main.php');
  7. //other files - rembmer to link your files to whatever.com?page=whatever - try changing $page at the top of the script to nothing, see if that makes it just ?=sdg, otherwise change it to something else, ie $var would make the URL's .php?var=sdg
  8. break;
  9.  
  10. case "tutorials":
  11. include('tutorials.php');
  12. break;
  13.  
  14. case "contact":
  15. include('contact.php');
  16. //add more of these as needed
  17. break;
  18.  
  19. case "VAR": //VAR is at the end of the url, so if somebody types in ...?=VAR it will include the file mentioned below
  20. include('contact.php');
  21. break;
  22.  
  23. } //End switch
  24. ?>
  25.  


if you want ?a=page&b=anotherpage Just add another switch! like so...

PHP Code
  1.  
  2. <?php
  3. case "page2":
  4.  
  5. switch($b) {
  6. default:
  7. include('page2.php');
  8. break;
  9.  
  10. case "page3":
  11. include('page3.php');
  12. break;
  13. }
  14.  
  15. break;
  16.  
  17.  
  18. //I wont explain that because it is the same thing up top
  19. ?>
chrism's Avatar
Author:
Views:
2,431
Rating:
Posted on Sunday 1st June 2008 at 03:12 AM
Adam981
Adam981's Avatar
Sorry for the double post. well i got a different switch PHP Navigation to work, so i'm guessing from looking at the code and what not that this wouldnt work for anyone, seeing that you might need a "GET" function.
Posted on Sunday 1st June 2008 at 02:09 AM
Adam981
Adam981's Avatar
Wow, i really cant make this work, when i go to link the page

example: "index.php?page=register"
it doesnt change the page and just includes main.php
Posted on Monday 7th April 2008 at 05:33 PM
Dalez
Dalez's Avatar
Hmm, i did this fine!

But when trying it with rmbs usersystem, when some of the pages use this, its messes up :(

And i dunno how to make it work :P
Posted on Monday 7th April 2008 at 03:14 PM
Dalez
Dalez's Avatar
Thanks, gonna try now!