GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Dec-2002, 04:23
ATCifpossible ATCifpossible is offline
New Member
 
Join Date: Dec 2002
Posts: 1
ATCifpossible is an unknown quantity at this point

Include by new PhP worker


I want to have different parts of my page (which are the same on every one) loaded by an include command.

For me this is new and i want to learn hot to make such. What i know till now:

For my page i want to have a 'header', a 'footer' and a 'mainlink' that is repeating on every other page in the same way.

How to make such:

I made the html for the header, footer and mainlink in wordpad and safed it into header.php.txt (etc for the other two)

I uploaded this and put it into an include folder in my hdocs.

Next i renamed the files and skipped the .txt so now all are name.php


---- What i not know is if i have to make such with only the code that i want to include or is it so that i have to make these files like a normal page (with head, etc in the code)?

---- The page where i want to include these .php files is a next step for me and what is the best for me to do? Can i make them in a normal editor or do i have to make such also in wordpad and rename them on the server into .php?

---- The pages are for several levels of the site and is there a way to make one kind of include so i can use this without changing every time the path to these .php files?

I hope you can give me the push to proceed.
  #2  
Old 30-Dec-2002, 20:11
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I'm hoping I'm answering your questions:

I'm giving you an example of how you're wanting your include()s to work
Quote:
Originally Posted by header.inc
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>Welcome to my site</p>
Quote:
Originally Posted by mainmenu.inc
<table width="20%">
<tr>
<td><a href="index.php">Home</a></td>
</tr><tr>
<td><a href="stuff.php">Stuff</a></td>
</tr>
</table>
Quote:
Originally Posted by footer.inc
</body>
</html>

And the index.php page that includes all these files will be like so:
Quote:
Originally Posted by index.php
<?php

include("header.inc");
include("mainmenu.inc");

echo "The absolute path to this file's directory is: ";
echo $_SERVER['DOCUMENT_ROOT']; //will print out the absolute path

include("footer.inc");
?>

There is nothing stopping you putting PHP code into any of the .inc files that you include, this will be run also!

You don't have to call the included files anything special, .txt will work just fine.

For your last question, try finding out the absolute path to the include files. On a Unix webserver, it may be something like /usr/www/sitename/header.inc. This file path will work no matter which directory the php script is in.

Hope I've helped

Garth Farley
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimizing your web server with Turck MMCache for PHP JdS Web Hosting Forum 2 07-Jan-2004 08:48
apache2 - php cgi fehler - schleife inna Apache Web Server Forum 8 27-Nov-2003 10:55
[Linux] Installing PHP --with-mcrypt JdS Web Hosting Forum 0 20-Aug-2003 09:40
[script] Password Protect web pages/site using PHP and MySQL JdS PHP Code Library 0 23-Jul-2003 11:02
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 17:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:42.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.