Most of us know what a pain it is to update a website when the links and content are constantly changing. So I’m going to provide you with a short and sweet bit of code to solve that problem.
It’s nothing fancy but it sure comes in handy. So I’m posting it back up by request of a few people.
The following steps are for a 3 column table with a header and footer. It’s just an example. I prefer divs myself.
- Create a new folder called “test”
- Inside your new folder create index.php and place the following code inside:
<? //***start of header ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="myspace stuff galore!" /> <meta name="keywords" content="flash players, layouts, glitters, goth" /> <title>My Site</title> </head> <body> <div align="center"> <table width="800" border="1" cellspacing="0" cellpadding="0"> <tr> <td height="100" colspan="3">your banner 800 X 100</td> </tr> <tr> <td width="130" valign="top"> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> links<br /> </td> <? //***end of header ?> <? //***start main content ?> <td width="640" valign="top">this is will all your content will go. </td> <? //***end main content ?> <? //***start of footer ?> <td width="130" valign="top">Google Ad! </td> </tr> <tr> <td colspan="3"><div align="center">© your site 2006 </div></td> </tr> </table> </div> </body> </html> <? //***end of footer ?>
<?php //***start of header ?>to <?php //***end of header ?>
and paste(CTRL+V) it into your header.html then save.
<?php //***start of footer ?>to <?php //***end of footer ?>
and paste it into your footer.html then save.
<? //***start main content ?>
<td width=”640″ valign=”top”>this is will all your content will go. </td>
<? //***end main content ?>
<?php
include(“header.html”);
?>
On the very bottom of your index insert this code
<?php
include(“footer.html”);
?>
Now whenever you want to change your banner or add links you only need to edit 1 file. The header.html file.
Whenever you want to change the footer and/or items in the right column like ads, you only need to edit the footer.html
For every new page, IE: contact, album, whatever, all you need to do it copy the index.php and change the content.
Your final product should look like THIS. If you view the source it looks like a simple html file.
Viola! we’ve just saved hours of work.


Sun, Apr 4, 2010
Development