include multiple pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dotphp
Forum Commoner
Posts: 25
Joined: Sat Nov 10, 2007 8:03 am

include multiple pages

Post by dotphp »

HY

I have index.php and pictures.php.
In index.php I have 3 columns:
- left (for menu)
- right (for advertising)
- center (where I want to include pictures.php)

What is the best way to include pictures.php in center of index.php

Code: Select all

if($_get[pictures]){
include ("pictures.php");
}
I ask this because I have multiple variable like "pictures" and I will have multiple "If".

Or to include in DB all this variables "pictures" and just add ".php" extension. It is secure in this way ?

Thanks
fugix
Forum Contributor
Posts: 207
Joined: Fri Mar 18, 2011 8:01 pm

Re: include multiple pages

Post by fugix »

the method that you have done here looks like what i would do...just add that code into the center column of your index.php page
User avatar
CrowderSoup
Forum Newbie
Posts: 18
Joined: Thu Apr 21, 2011 2:56 pm
Location: Murray, UT

Re: include multiple pages

Post by CrowderSoup »

fugix wrote:the method that you have done here looks like what i would do...just add that code into the center column of your index.php page
Agreed. If you're always going to be including "pictures.php" if the $_GET['pictures'] variable is true then there's no need to go to a database to get the file names. Unless you have tons of files you're going to be including...though from your post it sounds like at most you have only a few.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: include multiple pages

Post by social_experiment »

The Manual wrote:The include_once() statement includes and evaluates the specified file during the execution of the script. This is a behavior similar to the include() statement, with the only difference being that if the code from a file has already been included, it will not be included again. As the name suggests, it will be included just once.

Code: Select all

<?php
if($_get[pictures]){
// error control operator (@) incase the page cannot be found
@include_once("pictures.php");
} 
?>
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply