Ads

Navigation, the 'different' way

There are tons of different ways to navigate around and through your website using PHP. Here's one of the more common ways to navigate with php. It's simple, effective, and time saving.

Example Code:

CODE
<?php
switch($page) {
default:
include(
'news.php');
break; case 
"contact":
include(
'contact.html');
}
?>



Breakdown:
switch($page) - the $page is the variable your going to use to navigate, you can change that to whatever your heart desires but remember to change your href links also.
default: - is the default page included, if no variable is requested. eg. index.php?page= or index.php
case 'contact'; - is the requested variable. eg. index.php?page=contact
include('contact.html'); - is the page included when page=contact is retrieved.


Now to add the links.


CODE
Change <a href="contact.html">About</a>   to   <a href="?page=contact">contact</a>



And Volia, there you have it!
Any questions feel free to post!

Sunday May 27, 2007 - 91 reads