Lamez Posted September 26, 2007 Share Posted September 26, 2007 Ok I post yesterday about my menu.php I only want to edit one page when I add a menu item or when I move a page. Ok so I asked if I could do a include like this menu.php?page=index because I added a selection code to my css so my menu would like this (in HTML) <div class="menu"> <ul> <li class="selected"><a href="index.php">Home</a></li> [b]<-Selected: Indicates the user is on this page[/b] <li class="nonselected"><a href="_login/_members/members.php">Members</a></li> [b]<-Not Selected: Indicates the user is not on the page[/b] <li class="nonselected"><a href="login.php">Login</a></li> <li class="nonselected"><a href="register.php">Register</a></li> <li class="nonselected"><a href="info/info.php">Info</a></li> </ul> </div> Well I got an error in my include when I did that Warning: include(menu.php?page=login) [function.include]: failed to open stream: Invalid argument in C:\xampp\htdocs\JUNK\LAMEZ\login.php on line 56 Warning: include() [function.include]: Failed opening 'menu.php?page=login' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\JUNK\LAMEZ\login.php on line 56 So someone gave me this code <div class="menu"> <ul> <li class="<?php echo ($_SERVER['PHP_SELF'] == 'index.php') ? 'selected' : 'nonselected'; ?>"><a href="index.php">Home</a></li> <li class="<?php echo ($_SERVER['PHP_SELF'] == 'members.php') ? 'selected' : 'nonselected'; ?>"><a href="_login/_members/members.php">Members</a></li> <li class="<?php echo ($_SERVER['PHP_SELF'] == 'login.php') ? 'selected' : 'nonselected'; ?>"><a href="login.php">Login</a></li> <li class="<?php echo ($_SERVER['PHP_SELF'] == 'register.php') ? 'selected' : 'nonselected'; ?>"><a href="register.php">Register</a></li> <li class="<?php echo ($_SERVER['PHP_SELF'] == 'info.php') ? 'selected' : 'nonselected'; ?>"><a href="info/info.php">Info</a> </ul> </div> Well it did not work, at all Any Ideas? Was I clear enough? Link to comment https://forums.phpfreaks.com/topic/70710-solved-menuphp-i-do-not-know-a-good-subject/ Share on other sites More sharing options...
rlindauer Posted September 26, 2007 Share Posted September 26, 2007 You can't pass query string parameters in an include. Just set a variable in each page that menu.php will use to determine which link is "active". For example, index.php: <?php $current_page = "home"; include_once "menu.php"; ?> menu.php <div class="menu"> <ul> <li class="<?php echo ($current_page == 'home') ? 'selected' : 'nonselected'; ?>"><a href="index.php">Home</a></li> </ul> </div> Link to comment https://forums.phpfreaks.com/topic/70710-solved-menuphp-i-do-not-know-a-good-subject/#findComment-355424 Share on other sites More sharing options...
Lamez Posted September 26, 2007 Author Share Posted September 26, 2007 Wow this perfect, now I can only have one menu.php and edit one page when I want to do something! Thanks! Link to comment https://forums.phpfreaks.com/topic/70710-solved-menuphp-i-do-not-know-a-good-subject/#findComment-355429 Share on other sites More sharing options...
Lamez Posted September 26, 2007 Author Share Posted September 26, 2007 Figured it out Link to comment https://forums.phpfreaks.com/topic/70710-solved-menuphp-i-do-not-know-a-good-subject/#findComment-355435 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.