WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Website Engine
Categories : PHP, HTML and PHP, Templates Click here to Update Your Picture
Ronald Frederick
Date : May 21st 2004
Grade : 3 of 5 (graded 6 times)
Viewed : 4265
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Ronald Frederick
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

Ever wonder how others get their content to load in the same place and the menu, header and other regions of the site remain the same. Well, this example will show you how to create your own website engine.

Usage Example
URL: index.php?page=Contacts


SECTION ONE


This section shows the components of loading into the main content area (dynamic region) of your site.

1. The following specifies a default page or path+page.
Your primary (default) page will be called "_Home.php"

    <?php
   
if (!isset($page)) {
       
$page = "_Home";
    }
   
?>


2.        The following is what controls the path and what page to load.
        That is specified in the path set in the URL.
        
        
    <?php
    $LoadPage
= @include("$page.php");
   
?>


3.        The following will display a message if no page is found or if the path or page name are incorrect.
        
        
    <?php
   
if (!$LoadPage) {
        echo
"Sorry, the requested page is unavailable";
    }
   
?>



SECTION TWO


This section will show you how to load your "static regions" such as your menus, header, navbar and footers.

<?php
$header
= @include("_Header.php");
if (!
$header) {
    echo
"Header region could not get displayed";
}
$menu = @include("_Menu.php");
if (!
$menu) {
    echo
"Menu region could not get displayed";
}
$footer = @include("_Footer.php");
if (!
$footer) {
    echo
"Footer region could not get displayed";
}
?>


SECTION THREE

This section will show you how to put it all together using a table and the examples above.

Additional pages you will need to make yourself are:
_Home.php, _Header.php, _Menu.php, _Footer.php

NOTE: DO NOT include html, head or title tags in your added pages.

Begin engine

<?php
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
echo
"<html>\n";
echo
"<meta http-equiv=\"content-type\" content=\"text/html;charset=iso-8859-1\">\n";
echo
"<title>Site title goes here</title>\n";
echo
"<style type=\"text/css\" media=\"screen\">
        <!--
        body { color: #000000; font-size: 12px; font-family: Aria }
        td { color: #000000; font-size: 12px; font-family: Arial }
        a { color: #000000; font-size: 12px; font-family: Aria; text-decoration: underline }
        a:hover { color: #8B0000 }
        .Header_Region { background-color: #F0E4DD }
        .Menu_Region { background-color: #CDDBD8 }
        .Primary_Region { background-color: #F5F5F5 }
        .Footer_Region { background-color: #CEDBCD }
        -->
    </style>\n"
;
echo
"<body>\n";
echo
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo
"<tr>\n";
echo
"<td class=\"Header_Region\">\n";
   
// Displays header - _Header.php
$header = @include("_Header.php");
if (!
$header) {
    echo
"Header region could not get displayed";
}

echo
"</td>\n";
echo
"</tr>\n";
echo
"<tr>\n";
echo
"<td>\n";
echo
"<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"350\">\n";
echo
"<tr>\n";
echo
"<td width=\"160\" valign=\"top\" class=\"Menu_Region\">\n";

// Displays menu - _Menu.php
$menu = @include("_Menu.php");
if (!
$menu) {
    echo
"Menu region could not get displayed";
}

echo
"</td>\n";
echo
"<td valign=\"top\" class=\"Primary_Region\">\n";
   
// Displays primary content - Default page - _Home.php
if (!isset($page)) {
   
$page = "_Home";
}
$LoadPage = @include("$page.php");
if (!
$LoadPage) {
    echo
"Sorry, the requested page is unavailable";
}

echo
"</td>\n";
echo
"</tr>\n";
echo
"</table>\n";
echo
"</td>\n";
echo
"</tr>\n";
echo
"<tr>\n";
echo
"<td class=\"Footer_Region\">\n";

// Displays footer - _Footer.php
$footer = @include("_Footer.php");
if (!
$footer) {
    echo
"Footer region could not get displayed";
}

echo
"</td>\n";
echo
"</tr>\n";
echo
"</table>\n";
echo
"</body>\n";
echo
"</html>\n";
?>



PHP template processing
Categories : PHP, Templates, HTML and PHP
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
Alternating background color for HTML table rows
Categories : PHP, Databases, MySQL, HTML and PHP
Constantly refresh your PHP/HTML page data.
Categories : PHP, HTML and PHP, Sybase
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
background music script for random notes in a frame
Categories : PHP, Content Management, HTML and PHP
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL
PageRank Display
Categories : Search Engines, HTML and PHP, PHP
PhpView 0.1 - simple php viewer, using temporary files and frames.
Categories : PHP, PHP Options and Info, Debugging, HTML and PHP
Automatically printing the contents of an sql table in MySQL.
Categories : MySQL, PHP, HTML and PHP, Databases
Very minimal templating engine
Categories : PHP, PHP Classes, Templates