Jump to content

problem getting index.php?p=page&i=otherpage to work, please help!


petewall

Recommended Posts

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  ;)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.