...

View Full Version : How do I use PHP include files on all pages in my site



FlawedKid
05-04-2006, 03:27 PM
Note: Please ignore this title! Want I meant to type was "I have an Urgent PHP Problem and need Help"

I hope this title has gained some of your experts attention because I need some urgent help!

I am new to PHP hence the reason for this post, so I'll try and explain as clear as I can and get right into it..

Ok in this new site I am creating I am trying to eliminate heaps of updating so I am importing files like the header, footer externaly. My directory looks like this.

Root --> index.php, page1.pgp, page2.php etc
Root --> includes --> footer.php, header.php, right.php, left.php

The page left.php and right.php include the images for the page bar/headings.

But because I want to minimise updates and the right/left pages are loaded into all index.php, page1.php, page2.php pages the title text would have to be the same for all pages.

So my question is how can I include or place text dynamicaly into the left and right .php's?

I hope this makes sense :confused: if what iv said is unclear Ill be checking the thread every 6 seconds, (so I can explain in more detail if needed))

MRMAN
05-04-2006, 03:30 PM
Please read the Posting Guidelines.
Doubt you will get any help with the title "DO not view this thread!!!"

2) Type in a subject that summarizes your question- A great way to turn off other members wanting to help you is to type an incomplete or silly subject for your post.

FlawedKid
05-04-2006, 03:34 PM
Its a shame those guidlines exists sinse the purpose of this heading obviously worked. I am now reading the GLines for CS.com just incase I have violated anything else?

MRMAN
05-04-2006, 03:39 PM
this heading obviously worked
Don't think it did. i might have read the question but will not post a answer till the title is changed

FlawedKid
05-04-2006, 03:44 PM
How do i can a thread's heading? If you have a solution to my problem then please provide it along with how to change my posts title.

FlawedKid
05-04-2006, 04:01 PM
(Don't think it did. i might have read the question but will not post a answer till the title is changed)

Thanks mods for the title change, I guess we will see if MRMAN was correct and users will only respond with a "incomplete or silly subject for your post."...

goughy000
05-04-2006, 04:20 PM
So my question is how can I include or place text dynamicaly into the left and right .php's?

The same as you do any dynamic stuff in other pages?

Imrpove your question.. i dont see what your problem is :confused:

Crowds
05-04-2006, 04:28 PM
Is this what you are looking for ?

<?php include('includes/footer.php'); ?>

add this with the relavent page (footer.php, header.php) where ever you want the include to appear

Crowds

goughy000
05-04-2006, 04:31 PM
if crowds suggestion is right heres some more info

www.php.net/include

or..

www.php.net/include_once


and if the file is important enough for the script to stop if it cant be included

www.php.net/require
www.php.net/require_once

Crowds
05-04-2006, 04:37 PM
Thats right
As goughy000 says
using include instead of require will not call an error if the script breaks and all that will happen is your page will load but without the 'include' be it header.php, footer.php...

<?php include('includes/footer.php'); ?>

or


<?php require('includes/footer.php'); ?>

crowds

FlawedKid
05-04-2006, 05:10 PM
Thanks for the posts boys MRMAN was right :P however the advice give hasnt helped.

I'll try and explain what I mean a bit more cleary.
I have used <?php require('includes/right.php'); ?> // right heading box

Ok. so the right.php files is being imported to the index.php file.

Now I want to somehow..? Place text inside a cell in the right.php file from code in the index.php file.

Does this make sense? The reson I need to do this is because, If I didn't do this the title given in the right.php file would be the same for the pages... page1.php, page2.php etc

Is this clearer?

FlawedKid
05-04-2006, 07:20 PM
.....

Crowds
05-04-2006, 08:55 PM
Hmmm how about adding something like...

<?php $title = "my page title";?>

to your index page/page2/page3 ect

And adding something like


<?php echo "$title"; ?>

In your right page

"my page title" would need to be different for each page

Any good?

Crowds



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum