| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| New Member Join Date: Mar 2005
Posts: 9
![]() | 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. ????: NamePros.com http://www.namepros.com/programming/122733-include-files.html 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 Join Date: Jun 2005 Location: West Sussex, UK
Posts: 573
![]() ![]() | 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 Encenta.com; 09-11-2005 at 06:07 AM.
|
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Jul 2005 Location: Lithuania
Posts: 482
![]() | 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");
}
?> ????: NamePros.com http://www.namepros.com/showthread.php?t=122733 But first of all, make header and footer, as miseria mentioned. |
| |
| | THREAD STARTER #4 (permalink) |
| New Member Join Date: Mar 2005
Posts: 9
![]() | 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) |
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Meh... ![]() PHP Code:
Last edited by SecondVersion; 09-27-2005 at 08:11 PM.
|
| |
| | #8 (permalink) |
| Account Closed Join Date: Jul 2005
Posts: 102
![]() ![]() | kind of, i am budling like that... www.ipgfx.net/test/index1.php |
| |
| | #9 (permalink) | ||||
| NamePros Regular Join Date: Jul 2005 Location: Lithuania
Posts: 482
![]() |
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>. ????: NamePros.com http://www.namepros.com/showthread.php?t=122733 P.S. sorry for my broken english | ||||
| |
| | THREAD STARTER #10 (permalink) |
| New Member Join Date: Mar 2005
Posts: 9
![]() | NuPagady, thank you very much for this. Now it all works. And there is nothing wrong with your english ![]() Edit** Is it possible to change the numbers with words? Like this: index.php?page=downloads
Last edited by j0n87; 09-28-2005 at 05:29 AM.
|
| |
| | #11 (permalink) | ||||
| Senior Member Join Date: Mar 2005
Posts: 4,948
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
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 09:12 AM |
| Centering PHP included files | FreeBaGeL | Programming | 1 | 07-16-2005 12:01 PM |
| Using Music on your Site - WAV, MP3, MIDI, Flash? | abacomedia | Web Design Discussion | 1 | 05-20-2004 02:04 PM |
| 3 Char Domain & Great Domain Include Website For Sale! | eebay | Domains For Sale - Make Offer | 4 | 12-10-2003 12:43 PM |
| Include external files with out the use of server side technology | deadserious | CODE | 2 | 12-08-2002 11:43 AM |