1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

header body footer script in php for website

Discussion in 'PHP' started by finaldestination, May 15, 2006.

  1. #1
    i want to design a site that has a

    common header
    changable body
    and common footer

    the scriprt should be in PHP...
    SEMrush
    i shd be able to do some thing like this

    for each page

    {header}

    body---specify path for body

    {footer}

    Are u aware of any such free script...
     
    finaldestination, May 15, 2006 IP
    SEMrush
  2. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    
    include("header.php");
    
    ?>
    body content here
    <?php
    
    include("footer.php");
    
    ?>
    PHP:
    You can all the body content from a database if you want it to be database driven.
     
    mad4, May 15, 2006 IP
  3. MamboCube

    MamboCube Peon

    Messages:
    242
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you can then use a system where pages are loaded based on variables in the URL (although not recommended for SEO) using a case.php file.

    If you only have a small site then you might not need such a system, but if its quite large then you might find it easier in the long run.
     
    MamboCube, May 15, 2006 IP
  4. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    <?php include("header.php"); ?>

    body content here

    <?php include("footer.php"); ?>

    Yep that works for me.

    T
     
    Amsterdam, May 15, 2006 IP
  5. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    so i was looking around the forum an this sort of relates to what i was wondering..

    Besides adding the header.php footer.php files, what if i had a navigation bar in php that i wanted to add? what if i had two nav bars, one on the left an one on the right? an what if i wanted to have the header come in a little lower then standard? what would I do to change the placing and alignment, just regular html will work or would i need to code it in php? code would be nice if anyone has one, or a link pointing me in the right directoin would be sexy too.

    thanks in advance
     
    The Evil Penguin, Jan 1, 2007 IP
  6. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #6
    You can have as many included files as you need. If you had a page where you needed the menu to look slightly different you could set a variable before including the menu:
    $menu="lower";
    include('menu.php');
    Code (markup):
    And then in your menu.php file you could have
    if($menu=="lower"){
    // do something
    }
    Code (markup):
     
    mad4, Jan 1, 2007 IP
    The Evil Penguin likes this.
  7. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    this is the code to position them anyway an order i want? or i do that with just basic html?

    thankk you by the way, rep added
     
    The Evil Penguin, Jan 1, 2007 IP
  8. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #8
    The php code would generate the html code. You still need to write the html code to position the menu.
     
    mad4, Jan 1, 2007 IP
  9. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Dude, you have know idea how much your helping. Just need to bother you with a couple more of uber-noobness. What if I had a custom text field that I made in photoshop, can I put data from MySQL in it? Also, say I got my header.php, footer.php, leftnav.php, rightnav.php, and contentfield.php (depending on if this is possible) all in a new php file the way i want the site to look. Can i save that as say, template.php and do this:
    include("template.php") then use a command to send data from MySQL to contentfield.php? If thats possible I can just give save as a new name say: article.php, an have a link pointing to article.php an when the link is clicked itll be mysite.com/article.php. Am i understanding php correctly or am i just utterly hopeless.

    p.s.
    i love you, you've been the most helpful by far.:p
     
    The Evil Penguin, Jan 1, 2007 IP
  10. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You can use mysql commands in your contentfield.php file and populate it from your database no problem.

    The best thing is to just create article.php and then include all the pages to that.
     
    mad4, Jan 2, 2007 IP
  11. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    thank you once again for all the help. here is a post i made in another thread, wouldnt this suit me better?
    let me explain my project. I've been wanting to make a song lyrics page for quiet some time now. What would be the best way of going about this. On the main page, "mysite.com" i plan on having the layout an all that junks, but will update it daily with links pointing to the new lyrics added, or just telling which new lyrics were added(something along those lines but you get the idea) and have a mini nav bar on the top under the header with links from a-z. Clicking on a letter will send you to all artists with the letter A, letter B, ect ect, depdning on the letter you clicked. From there, clicking on an artist will send you to the artists page. Artist page will have brief description of artist/group then the links to all the artists song.

    What would be the easiest way of doing this? Ive heard the php approach would, but wouldnt a dreamweaver template be the easiest? Then when i make a new page with the dreamweaver template, add php code to get the lyrics from the database or something?

    Sorry if this is confusing, I confuse myself at times. If you need clarification or further info, just ask.

    Also, anyone else that might have tips or imput, feel free to reply.
    Thanks in advance
     
    The Evil Penguin, Jan 2, 2007 IP
  12. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #12
    Theres only one way to achieve such a site without having to maintain it yourself 24 /7, and that's using a server side language like php or asp.

    IT's quite a lot of work for someone that's just starting out, before you jump in that deep try some simpler stuff, things you will need eventually, like checking forms ( like users inputting lyrics ), find out how to read and write to databases / flatfiles, once you have done these two things you'll be armed with a lot of knowledge of how php works and it's role exactly in a website, at the moment you seem a little confused as to what php's function actually is, take my advice and come back post some forms you made, theres always someone to help with php so its an easy language to learn, and for the people that know it we love to tell others about it.....
     
    krakjoe, Jan 2, 2007 IP
    The Evil Penguin likes this.
  13. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Not really sure about dreamweaver templates, I don't use anything like that. Just a text editor.
     
    mad4, Jan 2, 2007 IP
  14. robster

    robster Peon

    Messages:
    94
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Sort of a question to go on top of his...

    I recently tried something like this, and added the includes on my php dreamweaver template...

    The idea was that if I want to change the bottom, left, top areas, I would only have to upload one file change (or database field ... but anyhow). The problem I ran into was that when I included the file from the include/ directory, if the page that was calling the include was in the root directory, everything worked fine.

    If the page calling it was in the root/Members/ directory, then all the links were messed up.

    What is the best way to use these in a template and still have everything point to the correct path for links/images/ect.

    ** I was hoping that by calling the php include, it would take the html and use the links relative to the path of the include directory **
     
    robster, Jan 2, 2007 IP
  15. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Always use absolute urls for images and links. That is rule 1 of web design.
     
    mad4, Jan 2, 2007 IP
  16. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    krakjoe, might take a couple weeks to have everything up but after that adding new songs shouldnt be that difficult since it will be basically taking data from a database an display it on the content field (i hear its really simple to do that with php)

    what im more interested in understanding is whats the best way to set up something where for every new artist or song i put, id just have to modify that certain page to show the content or artist link. layout and every other link already there(ads also there too if i decide to add ads), so i wouldnt need to do any unnesscary coding. and when i need to modify all links or the look of the site, just modifiy one page to effect all.

    can i make a template.php?
    mad4 sort of answered this question but im not sure if he understood what i was aiming at.

    Thanks in advance

    ---------------------------------------------
    Add this to your .htaccess file.

    Quote:
    AddType application/x-httpd-php .php .htm .html

    if did that, then made the page using dreamweaver an html an just said screw the other stuff, would i still be able to call the data from the database to show the lyrics stored there? an if yes, would this be easier?
     
    The Evil Penguin, Jan 2, 2007 IP
  17. robster

    robster Peon

    Messages:
    94
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #17
    ^^ haha ... duh, that would definately fix the problem.

    Surprised I didnt know that rule... guess I should have taken some classes on it back when I started.

    So is there SEO reasons for doing that, or is it just for the sake of making it easy to move files, or what? I mean, if it was all html pages, then what would the real benefit of doing that be? For PHP, it makes sense to me, dont get me wrong, but I would think that if it was really rule # 1 of "web design", something as popular as dreamweaver might make that the default for when you do the 'drag and point' in the link creation box in the properties tab.

    Any thoughts? ... is there a setting I can change in dreamweaver that would make that easier? It seems that dreamweaver will keep those links as relative paths because for development purposes, you dont always have images, files, scripts, or whatever uploaded to the main website, so linking to them on a development server would be fruitless.
     
    robster, Jan 2, 2007 IP
  18. mad4

    mad4 Peon

    Messages:
    6,989
    Likes Received:
    493
    Best Answers:
    0
    Trophy Points:
    0
    #18
    Having absolute urls makes developing offline on your PC hard. Since I never do that its not an issue for me.

    If somebody scrapes your pages, or you need to use folders on your site, relative urls stop working. If you don't use them then its not a problem.
     
    mad4, Jan 2, 2007 IP
  19. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    anyone????
     
    The Evil Penguin, Jan 2, 2007 IP
  20. The Evil Penguin

    The Evil Penguin Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    ok how was this page made?
    http://www.mylyricscentral.com/
    all the url extensions or whatever those things are called end in .html
    not a single one has a .php
     
    The Evil Penguin, Jan 3, 2007 IP