Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I use PHP include files on all pages in my site

    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 if what iv said is unclear Ill be checking the thread every 6 seconds, (so I can explain in more detail if needed))
    Last edited by FlawedKid; 05-04-2006 at 05:00 PM.

  • #2
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please read the Posting Guidelines.
    Doubt you will get any help with the title "DO not view this thread!!!"
    Quote Originally Posted by Guidelines
    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.

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Regular Coder
    Join Date
    Jan 2006
    Location
    Preston, Lancashire, England
    Posts
    285
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by FlawedKid
    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

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by MRMAN
    (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."...
    Last edited by FlawedKid; 05-04-2006 at 05:06 PM.

  • #7
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    PHP Freelancing!
    ByteForums!
    Scriptlance.comNeed a job done quick? post it on scriptlance! OR! your a programmer? sign up and get paid for these jobs!

  • #8
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is this what you are looking for ?
    PHP Code:
    <?php include('includes/footer.php'); ?>
    add this with the relavent page (footer.php, header.php) where ever you want the include to appear

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #9
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    PHP Freelancing!
    ByteForums!
    Scriptlance.comNeed a job done quick? post it on scriptlance! OR! your a programmer? sign up and get paid for these jobs!

  • #10
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 Code:
    <?php include('includes/footer.php'); ?>
    or

    PHP Code:
    <?php require('includes/footer.php'); ?>
    crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #11
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #12
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    .....

  • #13
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm how about adding something like...
    PHP Code:
    <?php $title "my page title";?>
    to your index page/page2/page3 ect

    And adding something like

    PHP Code:
    <?php echo "$title"?>
    In your right page

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

    Any good?

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •