PHP Menus Updating Includes Content

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
greekdish
Forum Newbie
Posts: 2
Joined: Tue Jan 27, 2009 12:29 pm

PHP Menus Updating Includes Content

Post 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??
pl_towers
Forum Newbie
Posts: 12
Joined: Tue Jan 27, 2009 12:59 pm

Re: PHP Menus Updating Includes Content

Post 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
greekdish
Forum Newbie
Posts: 2
Joined: Tue Jan 27, 2009 12:29 pm

Re: PHP Menus Updating Includes Content

Post 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. :?
pl_towers
Forum Newbie
Posts: 12
Joined: Tue Jan 27, 2009 12:59 pm

Re: PHP Menus Updating Includes Content

Post 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
 
 
}
 
 
Post Reply