title: Nested PHP switch include navigation
body: <p>I’m currently working on a small web project, and my plan is to build it all from the bottom up – to start by making a functioning website which uses only PHP, HTML and CSS, and then, if the user enables it, progressively enhance the website through the magic of Javascript, more particularly - jQuery.  However, I’ve been running into some problems on the PHP side of things, and since I’m merely novice when it comes to that scripting language, what I can’t figure out is simply:</p>
  
  <p><strong><em>How to implement one PHP switch include navigation inside another one?</em></strong></p>
  
  <p>To better clarify what I’m trying to achieve, let me show you a little mock up of what my site structure looks like:</p>
  
  <ul>
  <li>Header.php (Header)</li>
  <li>Page1.php (Content page 1)</li>
  <li>Page2.php (Content page 2)</li>
  <li>Page3.php (Content page 3)</li>
  <li>Page3.1.php (Content page 3 sub-content 1)</li>
  <li>Page3.2.php (Content page 3 sub-content 2)</li>
  <li>Page3.3.php (Content page 3 sub-content 3)</li>
  <li>Footer.php (Footer)</li>
  </ul>
  
  <p>As you can see, when it comes to this mock up, it’s on page 3 where I intend to nest one php navigation inside another one. This to enable some slideresque sub-navigation on that very page, but my efforts in doing that have so far been futile at best.
  As far as code goes, this is what I’ve managed to scrap together.</p>
  
    
  
  <pre><code>&lt;a class="link" href="index.php?id=page1"&gt;Page1&lt;/a&gt;
  &lt;a class="link" href="index.php?id=page2"&gt; Page2&lt;/a&gt;
  &lt;a class="link" href=” index.php?id=page3"&gt;Page3&lt;/a&gt;
  
  &lt;?php
  
    switch($_GET['id']) {
    default:
    include('page1.php');
  
    break; case "page2":
    include('page2.php');
  
    break; case "page3":
    include('page3.php');  // *Nested navigation goes inside this page
    }
  ?&gt;
  </code></pre>
  
    
  
  <p>*Inside of page3.php I’ve put pretty much the same code, only that it links to the sub-pages of that page (page3.1.php, page3.2, and page3.3.php ) instead.</p>
  
  <p>Unfortunately, this doesn’t seem to work – first of all, when I enter localhost/index.php I my web browser I get the following notice:
  Notice: Undefined index: id in C:\xampp\htdocs\php-navigation\index.php on line 26.
  However, when I click one of the links, or enter a url like index.php?id=page1 I don’t get that notice. So it seems like I need to define the ’id’ variable, but where and how to do that?</p>
  
  <p>In addition to that, the nested navigation on page 3 doesn’t work at all, instead, when clicking on of the links to the sub-pages, I get redirected to the index page. I might have to do with the URL:s , but then again, what do I know?</p>
  
  <p>Please help me figure out how to make this work - all help, even just a slight nudge in the right direction, is welcome and much appreciated- thanks in advance!</p>
  
  <p>/ Johan Wendesten</p>