OK here is the header from one of my pages:
- PHP: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
require_once("includes\DbConnector.php");
require_once('includes\Sentry.php');
require_once('includes\Validator.php');
$theSentry = new Sentry();
$Connector = new DbConnector();
$validator = new Validator();
error_reporting(E_ALL ^ E_NOTICE);
$userloggedin = false;
if (!$theSentry->checkLogin(2) )
{
$userloggedin = false;
}
else
{
$userloggedin = true;
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title>GarethWinter.com</title>
<link href="/new.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {font-size: 24px}
-->
</style>
</head>
<body>
<div id="Menu">
<u>This Site</u><br />
<?php
$sql = "SELECT * FROM links";
$getLinks = $Connector->query($sql);
while ($row = $Connector->fetchArray($getLinks))
{
$name = $row['urlname'];
$link = $row['url'];
echo '<a href="'.$link.'">'.$name.'</a><br />';
}
?>
<br />
<u>Other Sites</u><br />
<?php
$sql = "SELECT * FROM externallinks";
$getLinks = $Connector->query($sql);
while ($row = $Connector->fetchArray($getLinks))
{
$name = $row['urlname'];
$link = $row['url'];
echo '<a href="'.$link.'" target="_blank">'.$name.'</a><br />';
}
?>
<?php
if($userloggedin==true) //Only display the admin Links when the user is logged in.
{
echo '<br /><u>Admin Pages</u><br />';
echo '<a href="../cmsadmin/admin.php">Admin Page</a><br />';
echo '<a href="../phpmyadmin-2.8.0.2" target="_blank">Database Admin Page</a><br />';
}
?>
</div>
<div id="Header"><a class="style1" href="../cmsadmin/admin.php" title="Click here to Login to Gareth Winter.com">GarethWinter.com</a></div>
You can ignore most of the
PHP its because I have logins enabled. As you can see i have the Header and the links divs in this file as they will always be the same on every page.
Then i would call this in every page like so:
- PHP: Select all
<?php require_once("header.php"); ?> //This is where we call the header file.
<div id="Content">
<?php
$sql = "Select * FROM pagecontent WHERE page = 'home'";
if($result = $Connector->query($sql))
{
while ($row = $Connector->fetchArray($result)){
echo nl2br('<h1>'.$row['title'].'</h1>');
echo nl2br(''.$row['content']);
}
}
else
{
echo mysql_error();
}
?>
<br />
<br />
<br />
<b>PLEASE NOTE:</b> All items on this website belong to <a href="mailto:root@garethwinter.com">Gareth Winter</a> the Owner of this site. Also all photos on this website are property of Gareth Winter and it would be much appreciated if you were to ask permission before using them.<br />
</div>
</body>
</html>
You then see that i have a content div, which is different in every page that I have, but that its the only difference.
I hope this helps you to understand it a bit better.