How to change content without loading the page in php

It is very important to build a simple website.. and It is nice to look. and it reduce the time complexity to load a page.

Suppose we want to build a website where header, footer, sidebar all will be fix but only page body( content-discription)  will be changed then you need to follow the following tips.

suppose your website is very simple look like as below

Here there is only three part of website just for tutorial at the top of the table is header and last part of table is  footer which will not be changed . and at the midle part of  the table we will include all page here.

then

…………………….index.php……………………

<body>
<table width=”700″ border=”1″ align=”center” cellpadding=”0″ cellspacing=”0″>
<tr>
<td><?php include(“header.php”); ?></td>   //fix in the first table
</tr>
<tr>
<td>
<?php                                                  // positioning in the middle table
//all pages will include here

if(isset($_GET[‘s’])) {   $includepage=$_GET[‘s’];}
else{$includepage  =  1; }

switch($includepage)    {

case ” “:
include(“start.php”);
break;

case 1:
include(“start.php”);
break;

case 2:
include(“about.php”);
break;

case 3:
include(“contact.php”);
break;

default:
include(“start.php”);
break;
}
?>
</td>
</tr>
<tr>
<td><?php include(“footer.php”); ?></td>  // fix in the last table
</tr>
</table>

</body>

……………about.php………………..

<h2>About me</h2>
My name is hamim<br />
I live Rajshahi

………………… contact.php………………

<h2>Contact us</h2>
mail me

…………………header.php……………………

<h1 align=center>Shamim</h1>
<a href=”./”>Home</a>
<a href=”index.php?s=2″>About us</a>
<a href=”index.php?s=3″>Contact us</a>

…………………footer.php……………….

&copy; 2010. Shamim.com

…………………..start.php………………….

<h2>Welcome</h2>

………………….Style.css………………….

body
{
font-family: Arial;
}

h1
{
color: #ff0000;
}

h2
{
color: #0000FF;
padding: 5px 0 5px 5px;
margin: 0;
}

a
{
color: #00FF00;
text-decoration: none;
}

a:hover
{
color: #ff0000;
}

………………………………………………………………………………………………………..

yes done now you can start.. to customizing your own site..

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: