Jump to content

Best way to code a menu


Greenie

Recommended Posts

Hey all,

I've been trying to figure out the best way to code a menu so that it is easily updated. I thought of storing the menu options in a database, but then I've no way of defining submenu values unless I create several tables and then I'm not sure how I would reference them. I apologise if I'm not making much sense, I don't really know what I'm doing.

Is there a conventional, or better way of doing this?

Thanks,
Greenie.
Link to comment
https://forums.phpfreaks.com/topic/28812-best-way-to-code-a-menu/
Share on other sites

[code]<?PHP
if($_GET[switch]){
setcookie("view",$_GET[switch],time()+(60*60*24*5), "/", "");
header('Location:index.php?done');
}
?>
<html><head><title></title></head>
<body>
<?PHP
if($_COOKIE[view]==1){
echo "<a href='index.php?'>blabla</a><br />";
echo "<a href='index.php?switch=blank'>select new menu</a>";
}else if($_COOKIE[view]==2){
echo "<a href='index.php?'>blabla</a><br />";
echo "<a href='index.php?switch=blank'>select new menu</a>";
}else if($_COOKIE[view]==3){
echo "<a href='index.php?'>blabla</a><br />";
echo "<a href='index.php?switch=blank'>select new menu</a>";
}else{
echo "<a href='index.php?switch=1'>Menu 1</a><br />";
echo "<a href='index.php?switch=2'>Menu 2</a><br />";
echo "<a href='index.php?switch=3'>Menu 3</a><br />";
}
?></body></html>[/code]

Hurray for cookies, 1000 menus, one page.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.