Ryan's District
December 05, 2008, 04:24:49 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Ryan's District Lottery: Claim your ticket or check
Jackpot details  
 
   Home   Help Search Chat Calendar Chess Shop Login Register  
Digg This!
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: PHP include();, A very nifty trick  (Read 4820 times)
0 Members and 1 Guest are viewing this topic.
onlygodcanjudgemee
Newbie
*

Reputation: 1
Offline Offline

Posts: 1
4431.85 RD$

View Inventory
Send Money to onlygodcanjudgemee

View Profile Awards
« on: May 22, 2006, 07:39:31 AM »

Even if you don't know any php this trick is easy to use and will save you a lot of time when updating the layout of you site.

1. First make the layout of your site, leaving the table or field where you want the main content to appear blank. Save it as a .php.

2. Then put the content in individual files as plain text/ content.

3. Insert this code in the content area of your layout file:
Code:
<?php
$page 
$_REQUEST['page'];
if(!
$page){$page main.html}
include(
$page);
?>


4. The last step in using this trick is to alter your hyperlinks. Instead of linking to main.html and guestbook.html and so on, you know link to ?page=main.html

That's it!
Here's an example to help you understand better:

index.php
Code:
<html>
<head>
<title>This is a test</title>
</head>
<body>
<a href=?page=main.html>Mainpage</a> - <a href=?page=second.html>Second page</a><br><br>
<?php
$page 
$_REQUEST['page'];
if(!
$page){$page main.html}
include(
$page);
?>

</body>
</html>


main.html
Code:
This is the mainpage...<br>
It is nice


second.html
Code:
This is another page...<br>
It is also nice
Logged
Ryan's District
« on: May 22, 2006, 07:39:31 AM »

 Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Archive - WAP2 - WAP - imode
Sponsors: RAYAN.tv
-

Powered by MySQL Powered by PHP Powered by SMF 1.1.7 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.288 seconds with 32 queries.

Google visited last this page Yesterday at 09:53:29 AM