Page 1 of 1

PHP Menus Updating Includes Content

Posted: Tue Jan 27, 2009 12:32 pm
by greekdish
I need some quick help and Im pulling my hair trying to find this, and I am a php newbie.

What I need is for the menus of my website, when clicked, to determine what the content is that lods up under the topnav. As I have it right now...

Code: Select all

<body>
<?php include 'topnav.php' ; ?>
 
<?php include '$menu' ; ?>
 
</body>
So I want the topnav menu buttons assigned a $menu value, and when user clicks on it, the page loads up the respected content page. Is there an easy way to do this??

Re: PHP Menus Updating Includes Content

Posted: Tue Jan 27, 2009 1:06 pm
by pl_towers
you will need to use querystrings, you should try reading some tutorials on PHP, some good ones to have a look at are on the w3schools website http://w3schools.com/php/default.asp

Re: PHP Menus Updating Includes Content

Posted: Tue Jan 27, 2009 1:57 pm
by greekdish
thank you, I will look into it. I didnt want to have to learn all of PHP to do this little tidbit since I am in a rush. Much obliged.

Edit: Im not finding anything that pertains to what I want to do. :?

Re: PHP Menus Updating Includes Content

Posted: Fri Feb 06, 2009 5:47 am
by pl_towers
a very basic example would be.


menu links: index.php?page=1 index.php?page=2 index.php?page=3


code:

Code: Select all

 
 
switch($_GET['page']) {
 
case 1:
   //first page
    require_once("home.php");
break
 
case 2:
   //second page
    require_once("about.php");
break
 
 
 
case 3:
   //third page
    require_once("contact");
break
 
 
default:
   //default to first page
    require_once("");
break
 
 
}