title: Post result from a query via php in same page with Ajax
body: <p>I have a form on my website with 3 drop-down boxes. After user select an option from each one and hit submit the data is posted to an external php file, that makes an query to MySQL and then the page is reloaded and result posted. I'd like to make this more fancy - with ajax without reloading the page. the problem is I'm completely nube. I search interned and tried a couple of examples but no result. Here is the code:</p>
  
  <p><strong>HTML FORM:</strong></p>
  
  <pre><code>&lt;form name="showprice" id="showprice" method="post" action="&lt;?php echo $_SERVER['PHP_SELF']; ?&gt;"&gt;
  &lt;select name="country" id="country"&gt;
  &lt;option value=""&gt;Select Country&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name="industry" id="industry" onchange="setOptions(document.showprice.industry.options[document.showprice.industry.selectedIndex].value);"&gt;
  &lt;option value=""&gt;Select Industry&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name="quality" id="quality"&gt;
  &lt;option value=" " selected="selected"&gt;Select country and industry first.&lt;/option&gt;
  &lt;/select&gt;
  &lt;input value="Submit" type="submit" name="submit" id="submit"&gt;
  &lt;/form&gt;
  
  &lt;script  type="text/javascript"&gt;
  var frmvalidator = new Validator("showprice");
  frmvalidator.addValidation("country","req","Please select country");
  frmvalidator.addValidation("industry","req","Please select industry");
  frmvalidator.addValidation("quality","req","Please select quality");
  &lt;/script&gt;
  </code></pre>
  
  <p>NOTE: I have removed the options to save space.</p>
  
  <p><strong>The external view.prices.php:</strong></p>
  
  <p>It is in another folder and now I am calling the result with </p>
  
  <pre><code>&lt;?php include('includes/view.prices.php'); ?&gt;
  </code></pre>
  
  <p>Present code is:</p>
  
  <pre><code>if(isset($_POST['submit'])) {
  include ('config.php');
  $con1 = mysql_connect($server, $username, $password);
  if (!$con1)
  {
  die(&lt;b&gt;Could not connect: &lt;/b&gt; . mysql_error());
  }
  echo'&lt;br /&gt;&lt;br /&gt;&lt;table id="myTable" class="tablesorter" align="center"&gt;
  &lt;thead&gt;
  &lt;tr&gt;
  **some table headers (8 columns)**
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;';
  
  $cou = $_POST['country'];
  $ind = $_POST['industry']; 
  $qua = $_POST['quality'];
  
  $sql = "SELECT * FROM $ind WHERE quality=$qua AND desig=$cou ORDER BY id ASC" or  die('&lt;b&gt;Data Insert Error:&lt;/b&gt; ' . mysql_error());
  
  echo("&lt;tr&gt;
  **Some table results with 8 variables taken from the MySQL database**
  &lt;/tr&gt;");
  
  if (!mysql_query($sql,$con1))
  {
  die('Error: ' . mysql_error());
  }
  }
  echo    '&lt;/tbody&gt;
  &lt;/table&gt;';
  mysql_close($con1);
  }}
  else {
  echo '&lt;div class="grid_9"&gt;
  &lt;p&gt;&lt;b&gt;TIP:&lt;/b&gt; Pick country, industry and quality from the drop-down above and hit "Submit" button to view results.&lt;/p&gt;
  &lt;/div&gt;';
  }
  </code></pre>
  
  <p>Any help highly appreciated.</p>