About me Domain Credits Way out Refresh My blog My host Credit


October 01, 2018 ♥ v23 layout (Halloween theme!) September 07, 2018 ♥ v22 layout ♥ 8 backgrounds/patterns ♥ 4 textures ♥ 20 gradients ♥ 4 banners ♥ 40 colors ♥ 2 photoshop tutorials ♥ 4 miscellaneous tutorials April 03, 2018 ♥ v21 layout ♥ 10 backgrounds/patterns ♥ 14 textures ♥ 10 gradients ♥ 50 colors December 17, 2017 ♥ v20 layout ♥ new blog entry ♥ 6 gradients ♥ 6 banners ♥ 6 colors November 03, 2017 ♥ v19 layout ♥ new blog entry ♥ 10 textures ♥ 10 gradients (new category!) ♥ 2 banners ♥ 10 colors ♥ revamped links & pages July 16, 2017 ♥ new layout (v18) ♥ new blog entry ♥ 6 backgrounds/patterns ♥ 8 premade banners ♥ 10 color schemes (revamped) May 25, 2017 ♥ new layout (v17) ♥ new blog entry ♥ 16 color schemes ♥ 1 photoshop tutorial ♥ 1 miscellaneous tutorial


Terms Back pats Banners Textus Colors HTML Tuts CP Tuts Ps Tuts PHP Tuts Misc. Tuts


Welcome to Sasha's gfx corner Skyrose, here to provide quality resources since May 2014; take a look, read the Terms, grab whatever you like and enjoy. <3

chat with me

PHP Dynamic Include

This is, in my opinion, a bit easier and difficult than the normal PHP Include: easier in the code, and harder in the links.
As for the normal PHP Include, you start with an HTML page - for references to that part, use my PHP Include tutorial.

Once you have the HTML page, put it aside for a moment and, with your chosen editor, create four php files - one more than the classic include - and call them head.php, foot.php, index.php and main.php.

The first file, head.php, is where the HTML page's header goes; you simply copy the code on your HTML page and paste it on the file. For the file to work, the code has to look like shown here below.

<!DOCTYPE html>
<title>page title</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />


<div id="navigation">navigation here</div>

<div id="content">

Now you do the same copy and past routine with the second file, foot.php; final code has to look like below.



Here is where Dynamic PHP Include differs from common Include: the main.php will in fact have no php snippets, but only the site content - like this.


The index.php file will be even more different (and completely different from the classic include's).
Since it's very complicated also for me to copy and paste all index file code here, just download the file called home.php and rename it to index; don't touch anything on that file but the lines I'm gonna indicate you, or you'll end up messing it up and it'll no longer work.

The first line you have to touch is where it says what I show below.

include ("head.php");

You change only where it says 'head.php', renaming it head, top or whatever your header file is called.
Then you search where it says the following.

$include = 'main.php';
include ($include);

That is the link it uses to find your content pages.
Last, you go where it says what you see below...

include ("foot.php");

...and change only where it says 'foot.php' - to whatever your footer file is called.
The file names are not mandatory; as long as you match the parts I showed you to your files names, you can rename the four files to whatever you want.

Now comes the hard part, meaning the links...which is not that hard once you remember their construction, shown below.

<a href="index.php?page=page name">link name</a>

Always remember to put the index.php?page= before the page's actual name and not to add the *.php suffix; if you forget these rules, the links won't work.
There, the Dynamic PHP Include is done.

NOTE :: To have your full site done with PHP Include, you just have to copy the main.php for how many times how are your pages and fill them with your content.