title: Retrieve data from mysql based on select option
body: <p><strong>Hey Guys...  I am trying to retrieve data from mysql db based on option selected from select tag ( drop down list )</strong></p>
  
  <p><strong>This is my html code</strong> </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script&gt;
  function showUser(str)
  {
  if (str=="")
    {
    document.getElementById("txtHint").innerHTML="";
    return;
    } 
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open("GET","getuser.php?q="+str,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form&gt;
  &lt;select name="staff" onchange="showUser(this.value)"&gt;
  &lt;option value=""&gt;Select Staff&lt;/option&gt;
  &lt;option value="Ms.Shakthi"&gt;Ms.Shakthi&lt;/option&gt;
  &lt;option value="Ms.Priya"&gt;Ms.Priya&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  &lt;br&gt;
  &lt;div id="txtHint"&gt;&lt;b&gt;Person info will be listed here.&lt;/b&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Getuser.php code</strong> </p>
  
  <pre><code>&lt;?php
  $q = intval($_GET['q']);
  
  $con = mysqli_connect('localhost','willy','12345','test');
  if (!$con)
    {
    die('Could not connect: ' . mysqli_error($con));
    }
  
  mysqli_select_db($con,"test");
  $sql="SELECT * FROM test WHERE Staff = '".$q."'";
  
  $result = mysqli_query($con,$sql);
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;Name&lt;/th&gt;
  &lt;th&gt;Class&lt;/th&gt;
  &lt;th&gt;Syllabus&lt;/th&gt;
  &lt;th&gt;Motivated&lt;/th&gt;
  &lt;th&gt;Time&lt;/th&gt;
  &lt;th&gt;Doubts&lt;/th&gt;
  &lt;th&gt;Marking&lt;/th&gt;
  &lt;th&gt;Interesting&lt;/th&gt;
  &lt;th&gt;Methods&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysqli_fetch_array($result))
    {
    echo "&lt;tr&gt;";
    echo "&lt;td&gt;" . $row['Name'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Class'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Syllabus'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Motivated'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Time'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Doubts'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Marking'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Interesting'] . "&lt;/td&gt;";
    echo "&lt;td&gt;" . $row['Methods'] . "&lt;/td&gt;";
    echo "&lt;/tr&gt;";
    }
  echo "&lt;/table&gt;";
  
  mysqli_close($con);
  ?&gt;
  </code></pre>
  
  <p><strong>When I select an option, the data isn't retrieved</strong> </p>