How to include a header
Moderator: General Moderators
How to include a header
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!!!
d11wtq | Watch your language!!!
-
thegreatone2176
- Forum Contributor
- Posts: 102
- Joined: Sun Jul 11, 2004 1:27 pm
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
output a link table in php
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>
Code: Select all
include 'header.php';so i have done this so far.
Code: Select all
$header = ("");
echo $header;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>
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:
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:
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;Code: Select all
require_once("header.php");php to output html
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?
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
Code: Select all
include 'index.php';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?
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..
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.
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.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
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?
original: class="header other"
php: class=header other <---doens't work for second class?
-
andylyon87
- Forum Contributor
- Posts: 168
- Joined: Sat Jan 31, 2004 5:31 am
- Location: Dundee
doesn't output html correctly!
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?