# Using PHP to load multiple elements into a single page



## new_rez (May 20, 2008)

Does anyone know how I can do this?

Basically I want a seperate navigation, header and footer page. I have created the seperate pages, but im not sure of the command or how I can include them in the page.
The reason I ask about doing these seperate sections is so that I only need to update one page instead of having to through every page on my website and updtate.

Am I right in assuming that I can use php nested in divs? So say a footer div would have the php command to load the footer page into that div, the same goes for both the navigation and header divs.

If anyone could point me in the right direction I would be very appreciative. It will help me make my new website a lot more dynamic.

Cheers 
new_rez


----------



## panchoman (May 20, 2008)

use frames in html:
http://www.w3.org/TR/html401/present/frames.html


----------



## CrackerJack (May 20, 2008)

you can use frames or cells. either one will work. i like using cells.


----------



## new_rez (May 20, 2008)

CrackerJack said:


> you can use frames or cells. either one will work. i like using cells.



How do cells work?

I've used frames before but they made my website look ugly  tbh i probably used them wrong lol.


----------



## CrackerJack (May 20, 2008)

It's kinda hard to explain. I'll try my best, you can have multi cells on a single page. With cells they all don't have to be the same size. So gives more room to play with. And it just looks better. Everthing you can have on a webpage you can have in a cell. What are you using to make the site? Or are using notepad? lol

If your DW check this out: http://www.dreamweavertutorial.net/techniques/advanced-dreamweaver-8-cells/

Dreamweaver Tutorial: Splitting and Merging Cells
http://www.guidesandtutorials.com/dreamweaver_tables.html


----------



## new_rez (May 20, 2008)

Well, at first I wrote out the basic pages in notepad. Then I took them into dreamweaver, changed bits about, made the layout nice using css and divs and added in pictures. 
Now im just trying to make it easier to manage and im also improving on the layout/looks

Do you have a link to any website with cell examples?


----------



## CrackerJack (May 20, 2008)

new_rez said:


> Well, at first I wrote out the basic pages in notepad. Then I took them into dreamweaver, changed bits about, made the layout nice using css and divs and added in pictures.
> Now im just trying to make it easier to manage and im also improving on the layout/looks
> 
> Do you have a link to any website with cell examples?



yeah it's in the last post, was trying to find the website. I'll try to find you more.


----------



## panchoman (May 20, 2008)

i think frames would work out better?


----------



## Kreij (May 20, 2008)

Frames are being completely obsoleted in HTML. You may want to rethink that strategy.


----------



## panchoman (May 20, 2008)

Kreij said:


> Frames are bing completely obsoleted in HTML. You may want to rethink that strategy.



true that..  frames are like not used anymore...


----------



## ZenZimZaliben (May 21, 2008)

What you should really be using is a combo of Cells and PHP Includes. This way interior pages never have to be reloaded, so for instance a header, footer, nav bar.

You would have a file called x.php and it will contain all the code for the navigation page. 

<html>
<body>
<a href="http://www.example.com/index.php">Home</a> - 
<a href="http://www.example.com/about.php">About Us</a> - 
<a href="http://www.example.com/links.php">Links</a> - 
<a href="http://www.example.com/contact.php">Contact Us</a> 

Then on a different PHP page index.php from this page you call/include x.php. 

<?php include("x.php"); ?>
<p>This is my home page that uses a common menu/theme sitewide!</p>
</body>
</html>

once you get that far you can used CachedWithin so users browsers do not need to reload the page. makes editing and page loads much faster.


----------



## CrackerJack (May 21, 2008)

^agree, it will speed up load times


----------



## ZenZimZaliben (May 21, 2008)

And develop time. You make one change to x.php and any place you call/include it is changed as well.


----------



## new_rez (May 21, 2008)

ZenZimZaliben said:


> What you should really be using is a combo of Cells and PHP Includes. This way interior pages never have to be reloaded, so for instance a header, footer, nav bar.
> 
> You would have a file called x.php and it will contain all the code for the navigation page.
> 
> ...



Cheers dude, this is exactly what I was looking for! Now for global internet domination!


----------



## ZenZimZaliben (May 21, 2008)

Cool! Have fun.


----------



## Kreij (May 21, 2008)

Well done all.
You can do the same thing using CSS and JS if you want.

The new HTML standard is dumping a lot of stuff in favor of doing it in style sheets and scripts.

I agree with them. segregating the UI from the logic of the page is the way to go.
MS has done this with thier WPF and XAML, and in a coding environment where more than one person manages the code, it is far superior to static files full of bloated code.


----------

