View Single Post
kretara
Cynical Old Bastard
 
Join Date: May 2004
Location: The Hot, Hazey, Humid South
Send a message via AIM to kretara Send a message via Yahoo to kretara  
2004-05-21, 13:07

Quote:
Originally Posted by ast3r3x
To have the same code show up on everypage simple add this to your html (php must be installed on the server):

<?php
include('dir/to/file');
?>

I'm pretty sure that is how you do it. Your web page probably has to end in .php instead of html or whatever, it won't effect anything though.

You just put the repeating code in that file and then it will be placed wherever you have the include().

I'm sure someone will come tell me I'm wrong but I tried

If you want to learn PHP without buying a book there isn't a place better then php.net
If you want you can set php to parse .html pages to mask your use of php. Here is another example of a php include:

<?php>
include_once "left_nav.php";
<?>

You can make a file called left_nav.php and place it in a directory somewhere (in the apache htdocs tree), I suggest in the "folder" where your .html/.php files will be server from. left_nav.php will contain any text/html/php that you want.
include_once means what it says, only include this file once even if called more than once.

BTW: you can also nest includes, ie. have an include file call another include file.

Good Luck!

Last edited by kretara : 2004-05-21 at 13:09. Reason: forgot to add link to include_once
  quote