Thanks everyone for the help. I corrected the switch statement, but it still doesn't seem to work. You can see a live example here.
This is the source code for content.php:
Code:
<?php
//Snag the header:
include('head.php');
// Get the name of the page from the string query
// Set $page to "home" if a parameter is not passed
if ($_GET['page']) {
$page = $_GET['page'] . '.htm';
} else {
$page = 'index.htm';
}
// If file specified exists, include it in.
if (file_exists("pages/$page")) {
include("pages/$page");
//If page 1 has page 2, next/previous:
if (preg_match("/^(.*_page)(\d+)/", $page, $matches)) {
$prev_page = $matches[2] - 1;
$next_page = $matches[2] + 1;
echo("<p style=\"text-align: center\">");
if (file_exists("pages/" . $matches[1] . $prev_page . ".htm")) {
echo("<a href=\"{$_SERVER['PHP_SELF']}" .
"?page={$matches[1]}$prev_page\">Previous Page</a>");
$prev = 1;
}
if (file_exists("pages/" . $matches[1] . $next_page . ".htm")) {
if ($prev) {
echo(" ");
}
echo("<a href=\"{$_SERVER['PHP_SELF']}" .
"?page={$matches[1]}$next_page\">Next Page</a>");
}
echo("</p>");
}
// If page doesn't exist, display this error message.
} else {
echo("<h1 align=\"center\">Page cannot be found</h1>\n");
}
//Snag the footer
include('foot.php');
?>
And here is head.php:
Code:
<?php
//Declare what the title is based on the page
$title="$title";
switch($page){
case "index.htm":
$title = "Home";
break;
case "page1.htm":
$title = "Page 1";
break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<a href="?page=index">Click here to go home</a> <a href="?page=page1">Click here to go to page 1</a> </br>
Foot.php simply closes off the </body> and </html>.
What seems to happen (at least from the browser source point of view) is that <title> won't "echo" the title variable. If I try to view the source code from my internet browser, <title></title> is blank:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<a href="?page=index">Click here to go home</a> <a href="?page=page1">Click here to go to page 1</a> </br><p>This is the index.</p></body>
</html>
Thanks once again for any more assistance! :D