Jump to content


Photo

Php include menu


  • Please log in to reply
2 replies to this topic

#1 LouisW

LouisW

    Young Padawan

  • Members
  • Pip
  • 2 posts

Posted 05 May 2010 - 11:00 AM

hi guys,

i have been away from the website construction scene for a number of years but have decided to return as it still interests me.
I am creating a basic website but really want to the following.

i have created an area for content, i would like the content area to change using a php include, so every time i click the menu link, the content area changes to the page i require without loading the rest of the page. I have tried searching online for the tutorial but i cannot seem to find what i need. I hope i have explained this well enough, if i need to explain better please ask.

Thanks in advance

Louis.



#2 NDBoost

NDBoost

    Young Padawan

  • Members
  • Pip
  • 27 posts
  • Gender:Male
  • Location:Tempe, AZ

Posted 07 May 2010 - 06:00 PM

you're looking for something along the lines of this:

<?php 
switch($x) { 
default: 
include('../home.php'); 

break; case "tutorials": 
include('../tutorials.php'); 

break; case "snippets": 
include('../snippets.php'); 

break; case "script_downloads": 
include('../script_downloads.php'); 

break; case "banners": 
include('../banners.php'); 

break; case "code_lessons": 
include('../code.php'); 
} 
?>


#3 hk_

hk_

    Young Padawan

  • Members
  • Pip
  • 52 posts
  • Gender:Male
  • Location:lost

Posted 22 May 2010 - 03:56 PM

You could try this, should do the work

<?php
function load_module($area){
switch $area:
include $area.".php";
break;
}

if(isset($_GET['module'])){
 load_module($_GET['module']);
}else{
 load_module("home");
}
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users