I am working through a php CMS tutorial and I can't get my data to display. It's like my variable ($pg) is invisible. If I uncomment the first include in the content div, I get an error that content/.php can't be found (notice the missing file name). I am passing the values of home, blog, contact and gallery through the URL. I have home.php, blog.php, contact.php and gallery.php in a folder called content. Each of the files contains lorem ipsum text and that's all. I have added an error check and I get no errors...just an empty div.
My code is as follows:
<?php
// Setup document:
include ('config/setup.php');
//---------------------------------------------------
//Check if page variable is set
if ($_GET['page']='') {
$pg = 'home';
}else{
$pg = $_GET['page'];
}
//---------------------------------------------------
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Dynamic Sites LLC</title>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<div class="header temp_block">
<?php include ('template/header.php');?>
</div>
<div class="nav_main temp_block">
<?php include ('template/nav_main.php');?>
</div>
<div class="content temp_block">
<?php //include ('content/' . $pg . '.php');
// database connection, query
$q = "SELECT * FROM pages WHERE name = '$pg' AND status = 1 LIMIT 1";
$r = mysqli_query($dbc, $q);
$page = mysqli_fetch_assoc($r);
echo '<h1>'.$page['title'].'</h1>';
echo '<div class="content_body">'.$page['body'].'</div>';
?>
</div>
<div class="footer temp_block">
<?php include ('template/footer.php');?>
</div>
</body>
</html>
My nav_main.php is as follows:
<?php
## Main Navigation
?>
<a href="index.php?page=home">Home</a> -
<a href="index.php?page=gallery">Gallery</a> -
<a href="index.php?page=blog">Blog</a> -
<a href="index.php?page=contact">Contact Us</a>
Any help would be appreciated.
Aaron