#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    2
    Rep Power
    0
    I'm pretty new at php3 (and coding in general) and would appreciate any help. I would like to create a common header file, and my php pages would include this header file to be displayed at the top of the page. The thing is some php pages will need to have a few differences in the header. Instead of making a bunch of different header files, I'd like to make one, and a php script would display a different header depending on which page called the header. How would I do this? (Thanks!)
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Various ways this could be done. I'm assuming there are not major differences and still only be just a couple different options? Try this:

    $option=1;
    include('header.php3');


    inside header.php3 you can display different options based on the setting of $option (or even if it isn't set. One way could be:

    if (isset($option))
    {
    $file = "option".$option.".php3";
    include ($file);
    }

    That way your different options have their own include for ease of editing (which is why you're doing it this way anyway

    Plus you can add more options to the header very easily.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    2
    Rep Power
    0
    Thanks for the reply! But I think this isn't quite what I was thinking (if I'm reading your example right, which I may very well not be). What I'd like is all the different header options in one file(header.php3)

    So my header.php3 would look something like:
    ---
    option1
    <html>My calendar page header

    option 2
    <html>My Discussion forum header

    option 3
    <html>My links page header
    ---

    So say on my discussion page, I'd include the header.php3, and the correct header (option 2) would be displayed.

    Thanks

  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    In that instance you could use a switch..case construct, see the manual.

IMN logo majestic logo threadwatch logo seochat tools logo