Ryan's District Boards
September 03, 2010, 06:14:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Other sites in our network:
You are not allowed to view links.
Register or Login and You are not allowed to view links.
Register or Login (new) << free mp3 download   and many more sites
 
   Home   Help Search Calendar Shop Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: PHP include();, A very nifty trick  (Read 6424 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
« 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 Boards
« on: May 22, 2006, 07:39:31 AM »

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

 
Jump to:  

.
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.061 seconds with 31 queries.