Like Us Like Us Facebook Subscribe Subscribe us YouTube Whatsapp Share us Whatsapp Query Send your queries

PHP Single Page Application (SPA) using master page Concept

PHP Single Page Application (SPA) using master page Concept

My students learning PHP ask me to show how to make a single page web application (SPA) in PHP using master page concept. In this tutorial I am going to show you how to do it as simple as possible.

If you want to have HEADER,FOOTER ,LEFT & RIGHT, panel same of  more then one page, so we can use master page concept.

Copy  and save file in you project directory and run . In this example master.php is treat as a master file which includes specific file which called using hyperlink. Each link is associated with a unique value ,which is received in same page. The value of hyperlink will received using $_REQUEST[‘id’], Corresponding to hyperlink . switch called individual file which is created separately in the same directory as inbox.php, draft.php, compose.php, mail.php.

master.php
<table width=”684″ border=”1″ align=”center”>
<tr>
<td height=”445″><table width=”100%” border=”1″>
<tr>
<td height=”79″>&nbsp;</td>
</tr>
<tr>
<td height=”335″><table width=”100%” border=”1″>
<tr>
<td width=”21%” height=”327″><table width=”100%” border=”1″>
<tr>
<td><a href=”master.php?id=1″>Inbox</a></td>
</tr>
<tr>
<td><a href=”master.php?id=2″>Compose</a></td>
</tr>
<tr>
<td><a href=”master.php?id=3″>Draft</a></td>
</tr>
<tr>
<td><a href=”master.php?id=4″>Mail</a></td>
</tr>
</table></td>
<td width=”58%”>
<?php
$link_id=$_REQUEST[‘id’];
switch($link_id)
{
case 1:
include(‘inbox.php’);
break;
case 2:
include(‘compose.php’);
break;
case 3:
include(‘draft.php’);
break;
case 4:
include(‘mail.php’);
break;
default :
include(‘inbox.php’);
}
?></td>
<td width=”21%”>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>

inbox.php
<table width=”375″ height=”328″ border=”1″ bgcolor=”#CC6600″>
<tr>
<td height=”322″>&nbsp;</td>
</tr>
</table>

compose.php
<table width=”375″ height=”328″ border=”1″ bgcolor=”#663300″>
<tr>
<td height=”322″>&nbsp;</td>
</tr>
</table>

draft.php
<table width=”375″ height=”328″ border=”1″ bgcolor=”#66CC99″>
<tr>
<td height=”322″>&nbsp;</td>
</tr>
</table>

mail.php
<table width=”375″ height=”328″ border=”1″ bgcolor=”#999999″>
<tr>
<td height=”322″>&nbsp;</td>
</tr>
</table>

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Sanjay PrasadMarvin Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest most voted
Notify of
Marvin
Guest
Marvin

It still reloads the pages I though the point was for it to seamlessly transition.

Do you have any Query / Suggestion