eleven0 Posted February 8, 2008 Share Posted February 8, 2008 I'm trying to make a master menu for my site. I'm trying to use php to avoid having all those lines in every single page. here is what i got for my menu <?php <div id="menu"> <ul> <li<?php if ($_GET["page"] == "home" || !(isset($_GET["page"]))) echo " id=\"current\""; ?>><a href="index2.php">Home</a></li> <li<?php if ($_GET["page"] == "forums") echo " id=\"current\""; ?>><a href="index.php">Forums</a></li> <li<?php if ($_GET["page"] == "download") echo " id=\"current\""; ?>><a href="index3.php">Download</a></li> <li<?php if ($_GET["page"] == "contact") echo " id=\"current\""; ?>><a href="#">Contact</a></li> <li<?php if ($_GET["page"] == "help") echo " id=\"current\""; ?>><a href="#">Help</a></li> <li<?php if ($_GET["page"] == "other") echo " id=\"current\""; ?>><a href="#">Other</a></li> </ul> </div> here is what i got in CSS; #menu { clear: both; margin: 0; padding: 0 40px 0 0; font:12px/26px Tahoma, Sans-serif; text-transform: uppercase; height: 26px; } #menu ul { float: left; list-style: none; margin:0; padding: 0; } #menu ul li { display: inline; } #menu ul li a { display: block; float: left; padding: 0 8px; color: black; text-decoration: none; } #menu ul li a:hover { background-color: #666; color: #cccccc; } #menu ul li #current{ background-color: #474A41; color: #333; } How do i set my page with $_GET["page"] so the menu will work? Link to comment https://forums.phpfreaks.com/topic/90134-solved-php-menu-css/ Share on other sites More sharing options...
shedokan Posted February 8, 2008 Share Posted February 8, 2008 let's say your page is index.php so you use index.php?page=home Link to comment https://forums.phpfreaks.com/topic/90134-solved-php-menu-css/#findComment-462204 Share on other sites More sharing options...
phpSensei Posted February 8, 2008 Share Posted February 8, 2008 So the menu would work? It already works. If the $_GET is one of the links in the menu, its ID is "Current", which is the page the user is at. To make the pages using $_GET do $page = $_GET['page']; $page = (isset($page)) ? $page : "Home"; switch($page){ case 'Home': echo 'this is home'; break; case 'Forum': echo " HALLO THIS IS THE FORUMS"; break; default: echo "Page does not exists"; } Link to comment https://forums.phpfreaks.com/topic/90134-solved-php-menu-css/#findComment-462218 Share on other sites More sharing options...
eleven0 Posted February 9, 2008 Author Share Posted February 9, 2008 @phpSensei The menu in my first post doesn't work. How do i define those pages? I get error like this * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 14 id="current">Home * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 15 >Forums * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 16 >Download * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 17 >Contact * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 18 >Help * Notice: Undefined index: page in C:\Documents and Settings\8\Desktop\wamp\www\forums\header.php on line 19 >Other also, $page = $_GET['page']; $page = (isset($page)) ? $page : "Home"; switch($page){ case 'Home': echo 'this is home'; break; case 'Forum': echo " HALLO THIS IS THE FORUMS"; break; default: echo "Page does not exists"; } I get "undefined index page" for this one too. Link to comment https://forums.phpfreaks.com/topic/90134-solved-php-menu-css/#findComment-462238 Share on other sites More sharing options...
eleven0 Posted February 9, 2008 Author Share Posted February 9, 2008 never mind i got it working. Link to comment https://forums.phpfreaks.com/topic/90134-solved-php-menu-css/#findComment-462248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.