Code
<?php //get the url using the "server" command $page= $_SERVER['REQUEST_URI']; //separate the url into an array by splitting the address by the forward slash $page = explode("/", $page); //get the number of elements in the array and subtract by one to get the page name $page_count= count($page)-1; //set a variable for the page nameDISPLAY
$page2= $page[$page_count]; //if the array is empty, the page is index.php. Reset the variable to index.php if($page2=='')
{
$page2= "index.php";
}
//remove any variables in the url by splitting into another array using the "?" $pagename= explode("?", $page2); //the page name will by the first element of the array $pagename= $pagename[0]; ?> <!--build a table with cells for the image links in the navbar--> <table> <tr> <td> <table> <tr> <!--insert images based on the above page name. If the page is selected load one images otherwise load the nonselected image--> <td><a href="(INSERT LINK URL)"><img src="<?php if($pagename =="(INSERT FILE NAME AND EXTENSION)"){ echo "(INSERT IMAGE SELECTED URL)";} else{ echo "(INSERT IMAGE NONSELECTED URL)";}?>" alt="(INSERT ALT TEXT)"/></a></td> <td><a href="(INSERT LINK URL)"><img src="<?php if($pagename =="(INSERT FILE NAME AND EXTENSION)"){ echo "(INSERT IMAGE SELECTED URL)";} else{ echo "(INSERT IMAGE NONSELECTED URL)";}?>" alt="(INSERT ALT TEXT)"/></a></td> <td><a href="(INSERT LINK URL)"><img src="<?php if($pagename =="(INSERT FILE NAME AND EXTENSION)"){ echo "(INSERT IMAGE SELECTED URL)";} else{ echo "(INSERT IMAGE NONSELECTED URL)";}?>" alt="(INSERT ALT TEXT)"/></a></td> <td><a href="(INSERT LINK URL)"><img src="<?php if($pagename =="(INSERT FILE NAME AND EXTENSION)"){ echo "(INSERT IMAGE SELECTED URL)";} else{ echo "(INSERT IMAGE NONSELECTED URL)";}?>" alt="(INSERT ALT TEXT)"/></a></td> <td><a href="(INSERT LINK URL)"><img src="<?php if($pagename =="(INSERT FILE NAME AND EXTENSION)"){ echo "(INSERT IMAGE SELECTED URL)";} else{ echo "(INSERT IMAGE NONSELECTED URL)";}?>" alt="(INSERT ALT TEXT)"/></a></td> <!--the final image completes the navbar across the page if the links to not cover that area--> <td><img src="(INSERT IMAGE FILLER RIGHT SIDE URL)" alt="(INSERT ALT TEXT)"/></td> </tr> </table> <table> <tr> <td> <!--the subnav is an include again depending on the page name--> <?php if ($pagename == "(INSERT FILE NAME AND EXTENSION)") { include ('(INSERT SUBNAV URL)');}?> <?php elseif ($pagename == "(INSERT FILE NAME AND EXTENSION)") { include ('(INSERT SUBNAV URL)');} ?> <?php elseif ($pagename == "(INSERT FILE NAME AND EXTENSION)") { include ('(INSERT SUBNAV URL)');} ?> <?php elseif ($pagename == "(INSERT FILE NAME AND EXTENSION)") { include ('(INSERT SUBNAV URL)');} ?> </td> </tr> </table> </td> </tr> </table>
| Link 1 | Link 2 | Link 3 | Link 4 | Link 5 | |
| Sub navigation | |||||