indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : ServerSide
This Article...
Print Version
Add Comment
View Comments
ServerSide
Apache on Linux
Apache User Directory Configuration
PostgreSQL Configuration
CGI: What and How?
PHP Jump Start Guide
Arrays in PHP
PHP and HTML Forms
Variable Passing in PHP
PHP 'include'
Drop-down Menu Navigation in PHP
Edit Your Site Online Using PHP
PHP MySQL Polling System
Dynamic, Search Engine Friendly Pages
Quot Ticker Using SSI
Regular Expressions Reference
PHP File Browser
PHP DB Deletion/Approval Script
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

Dynamic Navigation Bar & Footer Using PHP

How about a navigation bar and a footer which is dynamically included in all the pages in your site? Suppose if you want to add new content to the navigation bar or change some information in the footer, just edit these files and upload it. And voila! All the 200 pages in your site is automatically updated!

You need to create the navigation file and the footer file separately. The files can have HTML tags inside them. But they should not be a self-contained HTML file having the <html> <head> & <body> tags. Also note that these files can have PHP instructions within valid PHP tags. These instructions will be processed by the PHP engine even though they have different extension. Suppose you have your footer file named "footer.dat", you can dynamically call this file in another PHP file thus:

<?
include "footer.dat";
?>

Note 1: If the footer file is located in some other directory, you may use the "../" and "directoryname/" conventions too. Instead of using the relative file path, the absolute path of the file on the server can also be used. But the "include" statement cannot be used to display files stored in external server.

Using the "include" statement you can create a template for your site, and manage your site more efficiently, as I do!

Note 2: If you want to display files residing in another server, you can use the PHP function readfile(). Usage:

<?php
readfile("http://server.com/file.php");
?>

- Subhash
Sep `01


User Comments

Add Comment

[Quick Stats: Number of main threads: 0, Number of sub-threads: 0]

Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.