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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.