title: How to pass multiple variables to URL with GET
body: <p>I have a php page that displays results from a mysqli query. </p>
  
  <p>At the top I have the ever present #perpage and order by selectors so the user can select what they want. </p>
  
  <pre><code>&lt;form action="" method="GET"&gt;
  &lt;select name="perpage" onchange="this.form.submit()"&gt;
  &lt;?php 
                                if (isset($_GET['perpage'])) {print"&lt;option value='".$_GET['perpage']."'&gt;".$_GET['perpage']."&lt;/option&gt;";}
                                if (isset($_GET['perpage']) &amp;&amp; $_GET['perpage']==10) {} else {print"&lt;option value='10'&gt;10&lt;/option&gt;";}
                                if (isset($_GET['perpage']) &amp;&amp; $_GET['perpage']==20) {} else {print"&lt;option value='20'&gt;20&lt;/option&gt;";}
                                if (isset($_GET['perpage']) &amp;&amp; $_GET['perpage']==30) {} else {print"&lt;option value='30'&gt;30&lt;/option&gt;";}
                                ?&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>and this one for the orderby</p>
  
  <pre><code>&lt;form action="" method=""&gt;
  &lt;select name="order" onchange="this.form.submit()"&gt;
  &lt;option value="asc"&gt;Ascending&lt;/option&gt;
  &lt;option value="desc"&gt;Descending&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>If my current URL is results.php?perpage=30 and i try and set the order by it bcomes results.php?orderby=desc and vice versa. I would need ot to simply append the second variable to the end of the URL if one is already set. </p>
  
  <p>have tried setting the action to the current URL using $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] and it does the same thing.</p>