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 Link to comment https://forums.phpfreaks.com/topic/216039-problem-getting-indexphpppageiotherpage-to-work-please-help/ Share on other sites More sharing options...
petewall Posted October 19, 2010 Author Share Posted October 19, 2010 bump, anyone? Link to comment https://forums.phpfreaks.com/topic/216039-problem-getting-indexphpppageiotherpage-to-work-please-help/#findComment-1123907 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.