title: PHP Setting Multiple Variables From URL Cleanly
body: <p>So I have a jumble of code that I'm sure there is a cleaner way to go about this.  Essentially I have a url with multiple variables within it.  Depending on the variable other variables are set.  The code below functions as expected, just trying to find a cleaner route if possible.</p>
  
  <pre><code>$sortby = $_GET['sort'] or $sortby = 'price';
  $direction = $_GET['dir'] or $direction = 'desc';
  $automake = $_GET['make'] or $automake = '';
  $autocat = $_GET['model'] or $autocat = '';
  $searchkey = $_GET['s'] or $searchkey = '';
  $autocondition = $_GET['cond'] or $autocondition = '';
  
  if ($sortby == 'price') { $sorting = '_auto_price'; $orderby = 'meta_value_num'; } 
  
  else if ($sortby == 'year') { $sorting = '_auto_year'; $orderby = 'meta_value'; } 
  
  else if ($sortby == 'make') { $sorting = '_auto_make'; $orderby = 'meta_value'; } 
  
  else if ($sortby == 'model') { $sorting = '_auto_model'; $orderby = 'meta_value'; } 
  
  else { $sorting = ''; $model = ''; $orderby = 'date'; }
  </code></pre>
  
  <p>Then I have a few links displaying to set new variables.  If you haven't guessed these are different ways to sort the page's content.  These are pretty ugly as well.  Again they work, just not very pretty.</p>
  
  <pre><code>&lt;ul class="breadcrumb"&gt;
  &lt;li&gt;&lt;strong&gt;SORT BY:&lt;/strong&gt;&lt;/li&gt;
  &lt;li style="padding:0 3px;"&gt;&lt;/li&gt;
  &lt;li&gt;Price: 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=price&amp;dir=asc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;UP&lt;/i&gt;&lt;/a&gt; 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=price&amp;dir=desc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;DOWN&lt;/i&gt;&lt;/a&gt;
  &lt;/li&gt;
  &lt;li style="padding:0 3px;"&gt;&lt;/li&gt;
  &lt;li&gt;Year: 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=year&amp;dir=asc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;UP&lt;/a&gt; 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=year&amp;dir=desc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;DOWN&lt;/a&gt;
  &lt;/li&gt;
  &lt;li style="padding:0 3px;"&gt;&lt;/li&gt;
  &lt;li&gt;Make: 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=make&amp;dir=asc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;UP&lt;/i&gt;&lt;/a&gt; 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=make&amp;dir=desc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;DOWN&lt;/a&gt;
  &lt;/li&gt;
  &lt;li style="padding:0 3px;"&gt;&lt;/li&gt;
  &lt;li&gt;Model: 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=model&amp;dir=asc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;UP&lt;/i&gt;&lt;/a&gt; 
    &lt;a href="/inventory?s=&lt;?php echo $searchkey ?&gt;&amp;make=&lt;?php echo $automake ?&gt;&amp;model=&lt;?php echo $autocat ?&gt;&amp;sort=model&amp;dir=desc&amp;cond=&lt;?php echo $autocondition ?&gt;"&gt;DOWN&lt;/a&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>