PHP Navigation Script Explanation
Line By Line: nav.php
This is a very simple script, it's mainly just printing out HTML commands. in fact, if we'd just wanted a list of links in a single file we could have made this a HTML file and not bothered with PHP!
The reason we use PHP here is because this script recognises which page the browser is currently on, and greys out the links to that page...
- Print out the table header.
Note - the default font colour is grey. So all we need to do to 'grey out' a link is to make sure it's not a hyperlink (in which case it'll be blue and underlined - or whatever the defaults are set to).
<? echo '<table border="0" ..... color="#777777">';
- If $PHP_SELF contains the string 'toc.php' then this is the contents page so just print the page description (followed by four spaces).
if (strstr($PHP_SELF,"toc.php")) { echo 'Contents '; }
- If $PHP_SELF doesn't contain that string - this isn't the contents page, so print the page description as a link.
else { echo '<a href="toc.php">Contents</a> '; }
- Repeat this procedure for all the pages in the website...
- Print out the HTML to close the table. End the PHP code.
echo '<tr><td bgcolor .... /table>';
?>
|
|