|
Posted by noSpAm0000 on May 14, 2005, 11:55 pm
Please log in for more thread options
On Sat, 14 May 2005 22:05:58 +0000, MK wrote:
> Dear friends,
>
> I have many HTML files and they all have some common HTML code which is
> basically bunch of tags which are in all the files. How can I put the common
> code in one file and then share it in all the files? It is some thing like
> following in all the HTML files which I have.
>
> <HTML>
> <HEAD> Common </HEAD>
> <BODY>
> .... Common code/tags
> </BODY>
> </HTML>
>
> I want to do this so that I don't have to edit all the files if some common
> code has changed. Your help is very much appreciated.
>
> Regards,
> MK
Try PHP. Its very simple code. If your server supports PHP, just include
this in your 'index.php' page wherever you want the changing content to go:
<?php
if (!isset($_GET['p'])) {
include("includes/default.php");
} else {
include("includes/" . $_GET['p'] . ".php");
}
?>
On your menu, or wherever the links go to load the different content, use
this code:
<a href="index.php?p=PageName">Link Text</a> (notice that the links do not
have a file extension. The php code adds .php to the link and grabs the
file from the includes directory).
All of your content should be saved in a directory called "includes" and
they should have the extension .php
If you have any questions, there are links to PHP tutorials on my website
at
http://s94621231.onlinehome.us (getting a domain name soon).
So you have:
-index.php (your 'common code' with the php code mentioned above)
-includes (directory that contains the files you want to include)
|