Results 1 to 5 of 5

Thread: new to php, please help

  1. #1
    Join Date
    May 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default new to php, please help

    I want to make an html file like this:

    index.php

    <?php include("header.inc.php"); ?>

    <?php include("content.inc.php"); ?>

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

    Then I want a command that will pick all this information up (same as what is shown with a rightclick showing source when running the inedx.php file) and save it to a new html file. How do I do that?

    Thank you in advance.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Can you be more descriptive on what you would like?
    I don't understand your question.
    Jeremy | jfein.net

  3. #3
    Join Date
    May 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks, I'll try.

    I have three files, as shown, and I use the index.php to run them.
    I then get an html file showing what was inside the three files, and it creates something like a homepage.
    When you rightclick on a homepage you can read the sourcecode, collect it all and copy to a notepad and save it to a new html file.

    Reason: All my headers and footers in about 100 hmtl files are identical, so I thought I could just work on the 'content' and somehow automate creating these 100 complete html files.

    This is the first step in something that might turn out to get too complicated, but that is what I am trying to do.

  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Ah, yea this is a common way of not repeating yourself when creating pages. So all you have to do is have the code exactly as it was before but in the other files. So let's say header.php contains the following:

    Code:
    <html>
    
    <head>
    <title>My site name</title>
    <link rel="stylesheet" type="text/css" href="styles/public.css/>
    </head>
    
    <body>
    and then the footer.php contains:

    Code:
    <div id="footer"> Copyright &copy; </div>
    </body>
    </html>
    Remember that you will have to rename your HMTL files to PHP files for the includes to work:

    Code:
    <?php include("header.php"); ?>
    Content Here...
    
    Bla bla <div> </div>
    
    Etc...
    
    At the end of the page now...
    
    <?php include("footer.php"); ?>
    And then you can always include another php content file mid way down if that is going to be repeated, hope you see how it works now,

    Jack.

    Edit: You could even add in a bit of dynamic content by setting your <title>My site name</title> to a variable (if it is a value that changes). So <title> <?php echo "$title"; ?> </title> and then set the title variable in the HTML file, like $title = "About";

  5. The Following User Says Thank You to Schmoopy For This Useful Post:

    olsen (01-18-2009)

  6. #5
    Join Date
    May 2008
    Posts
    17
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you I'll give that a try and see how I do. Looks good.

Bookmarks

Posting Permissions

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