This is a discussion on "Fetching files/pages from one 'template' page" within the PHP Forum section. This forum, and the thread "Fetching files/pages from one 'template' page are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Fetching files/pages from one 'template' page
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Fetching files/pages from one 'template' page
Hi guys,
At the mo I am using php function to fetch different data stored all in one page so that I only have to have the code for my header and navigation once and then I can display the different pages all from this page - if this makes sense. I have since been told that I should be storing the other pages content in different files and fetching them from their... cos my page/file will be too big otherwise... Does any1 have any idea how to do this please? I would really appreciate any help/examples. This is the way I am doing it currently <?php function getCSS($x) { if ($x == $_GET["Section"]) { echo "activeButton"; } else { echo "button"; } } ?> <td align="middle"><a class="<?php getCSS("")?>"href="index.php">Home</a></td> <td align="middle" width="1"><span class="style22"> | </span></td> <td align="middle"><a class="<?php getCSS("Registration")?>" href="index.php?Section=Registration">Free Registration</a></td> <?php switch ($_GET["Section"]) { case "Registration": Thanks very much Brain. |
|
|
|
|||
|
Re: Fetching files/pages from one 'template' page
You can either use require_once() or include_once()...
If you use require_once(), the web page will not run at all if it can't find the required file. If you use include_once(), the web page will continue to load if it can't find one of the files Here's an example: <?php require_once('includes/header.php');?> <h1> I am content </h1> <?php require_once('includes/footer.php');?> Without crapping on too much, I use require_once in pretty much every situation for a few reasons... Hope this helped! Jim. |
![]() |
| Tags |
| fetching, filespages, template, page |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problems with Organising Website Files - Folders Stop My Pages from Displaying | thebagman | Website Planning | 10 | Sep 4th, 2007 22:12 |
| Template? pages | Paul in London | Web Page Design | 1 | Apr 24th, 2007 18:55 |
| Finding un-linked or un-used pages and files??? | rjrichar40 | Starting Out | 3 | Apr 19th, 2007 21:53 |
| front page 2003 and psd files | faygirl | Scripts and Online Services | 4 | Nov 20th, 2006 14:31 |
| Css pages and page breaks | bjorkli | Web Page Design | 0 | Aug 12th, 2005 13:29 |