Building a menu

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
JeffElkins
Forum Newbie
Posts: 7
Joined: Tue Jun 24, 2003 12:50 pm

Building a menu

Post by JeffElkins »

Howdy,

I need to implement a selection menu within a php program for navigation to it's various functions. Currently, I'm hard-coding a single choice:


function1();
// function2();
// function3();

So, obviously, function1 executes in the case above. How can I present a menu so the user can choose a particular function? Or, can I call the program with a desired starting point?

i.e. program.php?function3();

Thanks!
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Easily done. In a link, set the variable 'view' (or whatever you like) to style1. IE: program.php?view=style1 or program.php?view=style2

Code: Select all

<?php
if ($view == "style1")
{
// Include function 1
function1();
}
elseif ($view == "style2")
{
// Include function 2
function2();
}
else
{
function_default();
}
?>
Hope this is what you were looking for.
Image Image
JeffElkins
Forum Newbie
Posts: 7
Joined: Tue Jun 24, 2003 12:50 pm

Post by JeffElkins »

Thanks!
Post Reply