petewall Posted October 16, 2010 Share Posted October 16, 2010 Hey, i'm having some troubles figuring out how you make something like this to work index.php?p=page&i=otherpage. On a site i'm currently creating i have an index-file that with the $_GET includes the requested page for example index.php?p=band but when you go to the "band" page, a few sublinks will appear, and when you click on them i want them to still be there (i tried doing just "index.php?p=subpage" but then the sublinks dissappears since you're no longer on the band-page. Here's the php-code that i've come up with so far: <?php foreach($links as $menuItem) { $menuItemList = ucwords($menuItem); $menuItemLink = str_replace(" ", "", $menuItem); //Om sida ej är defined, p=index if (!isset($_GET['p'])) { $_GET['p'] = 'index'; } //Checkar om p är satt if (isset($_GET['p'])) { $page = $_GET['p']; } //Kirrar länkarna, om menuItemLink != page outputtas detta if ($menuItemLink != $page) { echo "<li id='nav'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } //är menuItemLink == page outputtas detta elseif ($menuItemLink == $page) { echo "<li id='current'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } else { echo "<li id='nav'><a href='?p=$menuItemLink'>$menuItemList</a></li>"; } } ?> </div> </div> <div id="subnav"> <div id="subnavlinks"> <?php if ($page == 'band') { include_once 'navigation/band_nav.php'; } elseif ($page == 'music') { include_once 'navigation/music_nav.php'; } elseif ($page == 'events') { include_once 'navigation/events_nav.php'; } elseif ($page == 'fittanihoransomfan') { include_once 'navigation/fittanihoransomfan_nav.php'; } else (include_once 'navigation/index_nav.php'); ?> I hope it makes any sense and that someone can help me cause i'm really quite new to php. and please ignore the comments that are in swedish Quote Link to comment Share on other sites More sharing options...
petewall Posted October 19, 2010 Author Share Posted October 19, 2010 bump, anyone? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.