title: conditional header source based on server url path
body: <p><b>Problem:</b> I want to load a custom header file for each content type (<code>$categoryId</code>) on my CMS.  For example, if the url is "/?action=archive&amp;categoryId=1", I want it to include my "header_medicine.html" file.  </p>
  
  <p>I'm definitely a php noob, but I've tried to respect this forum and solve my question using the tips at <a href="https://stackoverflow.com/questions/6302559/conditional-code-based-on-url" title="conditional code based on url"> this post about conditional code based on url</a>, but the archive page still loads from my 'else' condition.  </p>
  
  <p>Here's the code: </p>
  
  <pre><code>&lt;?php $archive_url = parse_url($_SERVER['REQUEST_URI']);
  
  if ($archive_url['path'] == "/?action=archive&amp;categoryId=1")
      include "header_medicine.html"; 
  
      elseif ($archive_url['path'] == "/?action=archive&amp;categoryId=2")
      include "header_science.html"; 
  
      elseif ($archive_url['path'] == "/?action=archive&amp;categoryId=3")
      include "header_other.html"; 
  
      else 
      include "header.html";
  ?&gt;
  </code></pre>
  
  <p>Thanks for considering my question!  </p>
  
  <p><br>
  <b> Update: Solution </b></p>
  
  <p>For anyone who is interested, here is the working solution to the code problem I posted above (with simplified fileysystem syntax).  I didn't use the isset function that @Michael recommended in his code below.  Thanks to everyone who offered suggestions, I'm now one step closer to having a clue about php.</p>
  
  <pre><code>&lt;?php switch ($_GET['categoryId']) {
      case 1:
      include "header_medicine.html";
      break;
      case 2:
      include "header_science.html";
      break;
      case 3:
      include "header_other.html";
      break;
      default:
      include "header.html";
      }
  ?&gt;
  </code></pre>