Here's the all php code:
$slug = urldecode($_SERVER["REQUEST_URI"]);
$slug = preg_replace('/\/{2,}/', '/', $slug); // remove multiple occurences of '/' from request uri
if (strlen($slug) >= 1 && substr_compare($slug, '/', 0, 1) === 0){ // remove '/' from the start
$slug = substr($slug, 1);
}
if (!strlen($slug)) { // homepage slug
$slug = 'index.html';
}
$mysqli = new mysqli($mysql_hostname, $mysql_user, $mysql_password, $mysql_database);
if ($mysqli->connect_errno) {
exit();
}
if ($stmt = $mysqli->prepare('SELECT title, description, content FROM '.$tableName.' WHERE slug=?')) {
$stmt->bind_param("s", $slug);
$stmt->execute();
$stmt->bind_result($title, $description, $content);
$stmt->fetch();
$stmt->close();
}
$mysqli->close();
$pageExist = ($title != null);
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title><?php if ($pageExist) { echo $title.' - '.$siteTitle; } else { echo 'Error 404 - '.$siteTitle; } ?></title>
<?php if ($pageExist && isset($description)) { ?>
<meta name="description" content="<?php echo $description; ?>" />
<?php } ?>
</head>
<body>
<div id="wrap">
<header>
<div id="logo">
<?php echo $siteTitle; ?>
</div>
</header>
<nav>
static html code here
</nav>
<article>
<?php if ($pageExist) { ?>
<h1><?php echo $title; ?></h1>
<?php echo $content; ?>
} else { ?>
<h1>Error 404</h1>
<p> </p>
<p>We are sorry, but that location does not exist on this site.</p>
<?php echo '['.$_SERVER["REQUEST_URI"].']'; ?>