Page 1 of 1

include multiple pages

Posted: Sun Apr 24, 2011 9:05 am
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

Re: include multiple pages

Posted: Sun Apr 24, 2011 9:18 am
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

Re: include multiple pages

Posted: Sun Apr 24, 2011 10:04 am
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.

Re: include multiple pages

Posted: Tue Apr 26, 2011 1:14 am
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");
} 
?>