munky334 Posted October 30, 2008 Share Posted October 30, 2008 Hi there I'm a complete newbie , so please be patient. I have this very simple menu item , but I am not sure how to connect a form to my menu items , i.e. I need my search.php form to open once the user clicks on the search menu item. Please can someone take a look. Thanking you in advance. Regards. index.php <?php require_once("menuHandler.php"); ?> <html> <head> <title>MicroMetaSpider - Check website META information</title> <link href="style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="caption">Medex Information System</div> <div id="container"> <div id="menu"><?php createMenu('link-3'); ?></div> <div id="content"> <p>This is a Medex Index Page!</p> </div> </div> <div id="source">2008 - Medex Information Systems</div> </div> </body> </html> menuStruct.php <?php // Main menu items $mainMenu['Help'] = 'link-1'; $mainMenu['Admin Functions'] = 'link-2'; $mainMenu['Modules'] = 'link-3'; $mainMenu['Support'] = 'link-4'; $mainMenu['Others'] = 'link-5'; // Sub menu items $subMenu['Modules']['Patient Demographics'] = 'sub-link-1'; $subMenu['Modules']['Search'] = 'sub-link-2'; $subMenu['Modules']['Visits'] = 'sub-link-3'; $subMenu['Modules']['Reports'] = 'sub-link-4'; $subMenu['Others']['SubMenu-1'] = 'sub-link-11'; $subMenu['Others']['SubMenu-2'] = 'sub-link-12'; $subMenu['Others']['SubMenu-3'] = 'sub-link-13'; ?> menuHandler.php <?php function createMenu($actLink){ include_once('menuStruct.php'); echo '<table class="menutable">'; // Get actual Main menu $actMenu=''; foreach ($mainMenu as $menu => $link) { if ($link == $actLink) $actMenu = $menu; if (isset($subMenu[$menu])){ foreach ($subMenu[$menu] as $menuSub => $linkSub) { if ($linkSub == $actLink) $actMenu = $menu; } } } foreach ($mainMenu as $menu => $link) { echo '<tr><td><a href="'.$link.'">'.$menu.'</a></td></tr>'; if ( ($actMenu == $menu) && (isset($subMenu[$menu])) ){ foreach ($subMenu[$menu] as $menuSub => $linkSub) { echo '<tr><td><a href="'.$linkSub.'" class="submenu">'.$menuSub.'</a></td></tr>'; } } } echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/130686-connecting-a-form-to-a-menu-item/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.