Web Analytics Made Easy -
StatCounter PHP + HTML Related Question - CodingForum

Announcement

Collapse
No announcement yet.

PHP + HTML Related Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP + HTML Related Question

    Umm, I know that theres a certain PHP code, that nearly every website uses, which keeps the left column, right column, header, and footer of a site always the same...and just leaves room for the Content to be changed (This is done so that coders don't have to recode every page they build...).

    I'm talking about something like this:




    Now I have NO idea what that code is...or how to use it...could someone here please shed some light on the subject? :P

  • #2
    The easiest way to describe it ...

    You create several plain text files (using Notepad).
    These contain content, and can also contain some HTML.
    Name these something like, t1.txt, t2.txt, t3.txt ... etc.
    Each one would be the content for different pages.

    Now, at the very top of your "index.php", you have these lines:
    PHP Code:
    <?php
    // default page is 1 (no page specified)
    $page="t1.txt";

    // if a page is specified, use it ...
    if($_GET['t']){
    $page="t".$_GET['t'].".txt";
    }
    ?>
    Then further down in your "index.php" where you want that content to appear,
    you would add a line like this.

    <?php include($page);?>

    Now, you can load any of the various text files by doing this:
    index.php
    index.php?t=2
    index.php?t=3

    Comment

    Working...
    X