Multiple Sections Of Single Page, Dynamic Sections Of Pages

by Hiroshi on June 15, 2008

in Conditions

Sometimes it is good for dynamic website or if the website content is huge and still you want to keep less pages then you can divide the page into sections. In this case page will be one but on clicking different links, page content will be changed and reloaded.

Normal Link Format

<a href="defaultpage.php">Default Page</a>

Format Of Link In This Case Will Be Like This…

<a href="defaultpage.php?display=content2">Content 2</a>
<a href="defaultpage.php?display=content3">Content 3</a>
<a href="defaultpage.php?display=content1">Content 1</a>

PHP Code

<?php
 
$display=$_REQUEST["display"];
 
if ($display=='content2') {
?>
content 2 goes here.
<?php
}
elseif ($display=='content3') {
?>
content 3 goes here.
<?php
}
elseif ($display=='content1') {
?>
content 1 goes here.
<?php
}
else{
?>
content 1 goes here. This is the main content which will always show up if you did not click any link or when just default page is being called.
<?php
}
?>

By this you can change whatever in pages you want even the whole page including meta and all.

Download Exdamples

3 Examples Of Dynamic Content Download

Related Posts

Previous post:

Next post: