johnz
01-15-2007, 04:58 PM
To use PHP Includes, the first thing you will have to do is rename all your .html files to .php.
After you've done that, the concept is pretty simple. Lets say you wanted to include navigation to all your pages. You would code your pages just like you would normally. When you reach the part in your page where your navigation would go, you use the include.
<?php include("yournavfile.html"); ?>
so lets say you had a page like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="top"></div>
<div id="main">
<ul id="nav">
<li><a href="page1.php">Link1</a></li>
<li><a href="page2.php">Link2</a></li>
<li><a href="page3.php">Link3</a></li>
<li><a href="page4.php">Link4</a></li>
<li><a href="page5.php">Link5</a></li>
</ul>
<div id="footer"></div>
</div>
</body>
</html>
Instead of inserting your navigation into every one of your pages, you can just use the include from above.
So now your page should look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="top"></div>
<div id="main">
<ul id="nav">
<?php include("navigation.html"); ?>
</ul>
<div id="footer"></div>
</div>
</body>
</html
The file that you are including (navigation.html) will contain the code that you want included:
<li><a href="page1.php">Link1</a></li>
<li><a href="page2.php">Link2</a></li>
<li><a href="page3.php">Link3</a></li>
<li><a href="page4.php">Link4</a></li>
<li><a href="page5.php">Link5</a></li>
After you've done that, the concept is pretty simple. Lets say you wanted to include navigation to all your pages. You would code your pages just like you would normally. When you reach the part in your page where your navigation would go, you use the include.
<?php include("yournavfile.html"); ?>
so lets say you had a page like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="top"></div>
<div id="main">
<ul id="nav">
<li><a href="page1.php">Link1</a></li>
<li><a href="page2.php">Link2</a></li>
<li><a href="page3.php">Link3</a></li>
<li><a href="page4.php">Link4</a></li>
<li><a href="page5.php">Link5</a></li>
</ul>
<div id="footer"></div>
</div>
</body>
</html>
Instead of inserting your navigation into every one of your pages, you can just use the include from above.
So now your page should look like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title></title>
</head>
<body>
<div id="wrap">
<div id="top"></div>
<div id="main">
<ul id="nav">
<?php include("navigation.html"); ?>
</ul>
<div id="footer"></div>
</div>
</body>
</html
The file that you are including (navigation.html) will contain the code that you want included:
<li><a href="page1.php">Link1</a></li>
<li><a href="page2.php">Link2</a></li>
<li><a href="page3.php">Link3</a></li>
<li><a href="page4.php">Link4</a></li>
<li><a href="page5.php">Link5</a></li>