Page 1 of 1
How to include a header
Posted: Tue Jun 07, 2005 7:45 pm
by mkyb14
ok i am making a website for a client and thus am looking for a simlier way of recalling the links and header part of the html page. does anyone have an example of how i can have the header part in php from a diff file and recall it with a simple code in the pages so that all i have to do to update every pages header/links is update that one file and the rest will do according with the php code? PLEASE this guy is driving me up the wall.
d11wtq | Watch your language!!!
Posted: Tue Jun 07, 2005 7:59 pm
by thegreatone2176
very easy
look up include()
so you could stick everything in header.php then on every page include("header.php"); and then whne you want to edit you just edit that file
i think you posted in the wrong section but o well
Posted: Tue Jun 07, 2005 9:19 pm
by John Cartwright
I edited your title. Reguardless of how urgent your problem is we treat it with just as much priority as yours. Please make futur titles more relevant. Thanks
Moved to PHP-Code.
output a link table in php
Posted: Thu Jun 09, 2005 12:58 pm
by mkyb14
ok i'm looking to use php to output a table "html" for my links in php so that all i have to do is call
With in the pages so i'm not recopying to everypage and modifying the links is simplier.
so i have done this so far.
my question is how do i format this in php so that it outputs correctly?
I don't need a full conversion but a few lines and i'll do the rest so that i know how to format html within php correctly. googling this has only gotten me some wierd or more complex versions of this. PLEASE HELLLLLP
<table width="700px" border="0" cellpadding="0px" cellspacing="0px" align="center">
<tr>
<td width="15%"> </td>
<td class="center_table" width="700px">
<div id="title"><img src="images/title.png" width="700px" height="116px"></div>
<center>
<div class="menu" align="center">
<a href="#" target="_self" class="menu_left" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Home</a>
<a href="bio.php" target="_self" class="menu_right" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Biography</a>
<a href="resume.php" target="_self" class="menu_right" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Resume</a>
<a href="pictures.php" target="_self" class="menu_right" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Pictures</a>
<a href="projects.php" target="_self" class="menu_right" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Projects</a>
<a href="links.php" target="_self" class="menu_right" onmouseover="style.backgroundColor='#cccccc';" onmouseout="style.backgroundColor='#f1f1f1'">Links</a>
</div>
</center>
Posted: Thu Jun 09, 2005 1:15 pm
by Burrito
I'm confused now. at first you wanted information about how to include a header that is a central location for html (links etc).
include(), require(), require_once etc. will work.
so now do you want information about how to create a string of html and then output it?
if so:
Code: Select all
$stuff = "<table width=\"700px\" border=\"0\" cellpadding=\"0px\" cellspacing=\"0px\" align=\"center\">
<tr>
<td width=\"15%\"> </td>
<td class=\"center_table\" width=\"700px\">";
echo $stuff;
obviously using the scenario you first described, you'd want to include that (assuming it's going to be your header info) in the header.php file then include it with:
php to output html
Posted: Thu Jun 09, 2005 8:47 pm
by mkyb14
ok i'll try to clarify.
I'm looking to take a section of html code which is my links and create a header.php. now within the header.php just have it setup so that in my other pages i can just call
or your require function (which i dunno what that does).
ultimatly so that when i edit the links or add them in the future i'm only editing the header.php and not 8 pages of html to change the links to be the same for all the files.
.... does this make sense?
Posted: Fri Jun 10, 2005 2:20 am
by Syranide
haven't you just answered your own question?
include does what you want... unless I'm totally missing the point.
require btw is the same as include, but bails on error.
Posted: Fri Jun 10, 2005 3:40 am
by phpScott
first create your index.html page.
secondly anything that you want to include as a header on every page cut out and save as header.php
save your index.html page as index.php
on your index.php page at the top where your code you cut out was do..
Code: Select all
<?php
include ('header.php');
?>
//rest of your html code here.
you then should be able to do this for any other page.
just remember to save then as .php pages otherwise your include statement won't work.
I know simple example but it should get you going.
answered
Posted: Sat Jun 11, 2005 1:31 pm
by mkyb14
yea i did answer it myself. plus you have to remove all the "" in the php file unless there is another way to seperate items such as multiple class's being called in php
original: class="header other"
php: class=header other <---doens't work for second class?
Posted: Sun Jun 12, 2005 12:49 pm
by andylyon87
if you have include("header.php");
you don't actually you can search for the " and replace with /" and that cancels out all the "" in php but will display them in html so you can have a spaced class.
doesn't output html correctly!
Posted: Wed Jun 15, 2005 6:28 pm
by mkyb14
your { /" } doens't output the html correctly as well as images etc. so then what do you use instead of {""} for html being outputed by php?