| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| New Member | Include files Hi I have a website made in html. I got like 20 different pages in the site, and i have just copied the index.html 20 times and changed the content in every page. When i want to change something in the Menu, i have to edit all 20 files, and that take too much time. Now i got a php host, and want to use the Include php thing. I want like the Header and Menu as index.php, and use <?php include("index2.php") ?> in the content. ![]() I've searched around in google, but didnt find enough info about this, so i hope you guys can help me. Thanks |
| |
| | #2 (permalink) |
| SQLdumpster.com | include("filename.php"); means just include the code from that file include once("filename.php"); means include the code from that file but no more than once. require("filename.php"); means include the code from that file but if there's an error, don't open the rest of the code. Something like that anyway. Sorry, I'm half asleep __________________________________________________ Further more... I remember when I first started using includes and I didn't realize it included the code rather than the design in Dreamweaver (I was stupid ). But code the 'index.php' first of all, then take portions of it (the header and the menu will probably be a good idea if the menu is on the left) and save it as "head.php". Then in the index.php, use ..PHP Code: Last edited by miseria; 09-11-2005 at 05:07 AM. |
| |
| | #3 (permalink) |
| NamePros Regular | Also, you have mentioned that you have 20 pages, so you can use something like that: Code: <?
switch ($_GET["page"]) {
case 1:
include("index1.html");
case 2:
include("index2.html");
case 3:
include("index3.html");
case 4:
include("index4.html");
}
?>
But first of all, make header and footer, as miseria mentioned. |
| |
| | #4 (permalink) |
| New Member | i got what u said miseria, but not what NuPagady said. can you explain better, or someone else? with the whole code? this is what i tried, but didnt success: PHP Code: |
| |
| | #6 (permalink) |
| NPQ's PA, Slave, and On Call Coder Technical Services | Meh... ![]() PHP Code:
__________________ Last edited by SecondVersion; 09-27-2005 at 07:11 PM. |
| |
| | #8 (permalink) |
| Account Closed | kind of, i am budling like that... www.ipgfx.net/test/index1.php |
| |
| | #9 (permalink) | |
| NamePros Regular | Quote:
Ok, I made an example for you. First of all, visit the link below to see how it works: http://www.nupagady.info/j0n87/ There are 6 files in the folder: index.php, head.php, foot.php, content.php, downloads.php and empty.php index.php: Code: <?
include("head.php"); // 1. script will include header
switch ($_GET["page"]) { // script will check variable "page" from the link
case 1: // If the link is index.php?page=1, it will include "content.php"
include("content.php");
break;
case 2: // If the link is index.php?page=2, it will include "download.php"
include("downloads.php");
break;
default: // If variable "page" is not specified, script will include "empty.php"
include ("empty.php");
}
include("foot.php"); // script will include footer
?>
Code: This is header <br> ------------------------------------------------- <br> Code: <br> ------------------------------------------------- <br> This is footer Code: "content.php" file.<br> If you'd like to include "downloads.php", <a href="index.php?page=2">click here</a>. Code: "downloads.php" file.<br> If you'd like to include "content.php", <a href="index.php?page=1">click here</a>. Code: If you'd like to include "content.php", <a href="index.php?page=1">click here</a>;<br> If you'd like to include "downloads.php", <a href="index.php?page=2">click here</a>. P.S. sorry for my broken english | |
| |
| | #11 (permalink) | |
| NPQ's PA, Slave, and On Call Coder Technical Services | Quote:
PHP Code:
__________________ | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Totorial - Adding Music to your Site | abacomedia | Webmaster Tutorials | 7 | 08-27-2005 08:12 AM |
| Centering PHP included files | FreeBaGeL | Programming | 1 | 07-16-2005 11:01 AM |
| Using Music on your Site - WAV, MP3, MIDI, Flash? | abacomedia | Web Design Discussion | 1 | 05-20-2004 01:04 PM |
| Include external files with out the use of server side technology | deadserious | CODE | 2 | 12-08-2002 10:43 AM |