0% found this document useful (0 votes)
58 views6 pages

($pageid $nav) $nav $nav

The document outlines the code for a basic PHP/MySQL content management system. It includes configuration files, functions, templates and sample pages to display content from a database and manage navigation.

Uploaded by

Andrew Moonga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views6 pages

($pageid $nav) $nav $nav

The document outlines the code for a basic PHP/MySQL content management system. It includes configuration files, functions, templates and sample pages to display content from a database and manage navigation.

Uploaded by

Andrew Moonga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Navigation

<li<?php if ($pageid == $nav['id']){echo ' class="active"';}?>><a


href="<?php echo $nav['id']; ?>"><?php echo $nav['LEBEL']; ?></a></li>

<?php
// Setup File:

# Database connection here ...


$dbc = mysqli_connect('localhost', 'Amos', '251349','Myweb') OR die('Could not
connect because: '.mysqli_connect_error());

# Constants:
DEFINE('D_TEMPLATE', 'template');

# Functions:
include('functions/data.php');
include('functions/template.php');

$site_title = 'MALCOLM MOFFAT COLLEGE OF EDUCATION';

if (isset($_GET ['page'])) {

$pageid = $_GET ['page']; // set $pageid to equal the value given in the
URL
} else {

$pageid = 1; // set $pageid equal to 1 or the home page.

# Page Setup
$page = data_page($dbc, $pageid);

?>
Index.php

<?php
include ('config/setup.php'); ?>

$q = "SELECT * FROM pages WHERE Id = 1" ;


$r = mysqli_query($dbc, $q);

$page = mysqli_fetch_assoc($r);

echo $page['title']

<!DOCTYPE html>
<html>

<head>

<title> <?php echo $page['title']. ' | '. $site_title ?> </title>


<meta name="viewport" content="width=device-width, initial-scale=1.0">

<?php include ('config/css.php');?>


<?php include ('config/js.php');?>

</head>

<body>
<div id="wrap">

<?php include(D_TEMPLATE.'/navigation.php'); // main navigation ?>

<div class="container">

<h1><?php echo $page['header']; ?></h1>


<p><?php echo $page['Body']; ?></p>
</div>

</div><!-- END wrap -->


<?php include (D_TEMPLATE.'/footer.php'); //page footer ?>
</body>

Navigation.php
<nav class="navbar navbar-default" role="navigation">

<div class="container">

<ul class="nav navbar-nav">


<?php nav_main($dbc, $pageid); ?>

<li><a href="#">Faq</a></li>
<li><a href="#">Log IN</a></li>

</ul>

</div>
</nav><!-- End nav -->
Footer.php

<footer id="footer">

<div class="container">
<center> <p>MALCOLM MOFFAT COLLEGE OF EDUCATION.</p> </center>
<center> <p> Copyright © 2018 Mj & SHEM Arts</p> </center>
</div>
</footer><!-- END footer -->
Template.php
<?php

function nav_main($dbc, $pageid) {

$q = "SELECT * FROM pages";


$r = mysqli_query($dbc, $q);

while($nav = mysqli_fetch_assoc($r)){ ?>


<li<?php if($pageid == $nav['id']) {echo 'class="active"';}?>><a
href="?page=<?php echo $nav['id']; ?>"><?php echo $nav['LEBEL']; ?></a></li>

<?php }
}

?>

You might also like