title: PHP/HTML dynamic page/search
body: <p>I'm finding it hard to get my head around the logic around this issue I'm having.</p>
  
  <p>Currently, I have a search.html page that on submit goes to Results.php. There is then some code that searches the mysql for whatever was inputted into the search page.</p>
  
  <p>Now, How would I go about having the search and the results on the same page? How would i return the variable from the search page? For example before I was using;</p>
  
  <pre><code>$search_term = $_POST['name'];
  </code></pre>
  
  <p>How would I get the 'name' variable if its on the same page?</p>
  
  <p>EDIT: Second issue</p>
  
  <p>I have the code working that many of you answered with, thank you very much! I've now come to my second problem. I have two inputs a textbox for the search query and then a dropdown box for a subject to search.</p>
  
  <p>Then user then presses submit and the db is searched, this all works fine. I now want to create another dropdown box so the user can sort the provided results in a matter that they see fitting, for example price high to low etc.</p>
  
  <p>I have the HTML code already done but as you can imagine, the second I press submit its reloading the page and as it doesn't know what the user has previously searched it exits the php and acts as if its a fresh page load.</p>
  
  <p>URL: <a href="http://helios.hud.ac.uk/u0862025/db/test.php" rel="nofollow">http://helios.hud.ac.uk/u0862025/db/test.php</a></p>
  
  <p>Play around with it, press submit to lift all products in the database.</p>