title: Ajax Mysql Query
body: <p>I am propably being a complete idiot and not seeing the big picture here. I am trying to write a little ajax thingie that would pull information from a database but i cant seem to get the thing going ... please tell me what i am doing wrong. </p>
  
  <p>I put the code together by following a couple of online tutorials and i am no ajax genius. my ajax skills could propably start the next world war. </p>
  
  <p>Here is my code. please feel free to tell me im an idiot if i missed something small. </p>
  
  <pre><code>     &lt;html&gt;
  &lt;head&gt;
      &lt;script&gt;
          function showDetail(str) {
              if (str=="") {
                  document.getElementById("txtHint").innerHTML="";
                  return;
              }
              if (window.XMLHttpRequest) {
                  // code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
              } else { // code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
              xmlhttp.onreadystatechange=function() {
                  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) {
                      document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                  }
              }
              xmlhttp.open("GET","process.php?q="+str,true);
              xmlhttp.send();
          }
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form&gt;
      Wallet Number : &lt;input type="text" name="wallet01" id="wallet01"  /&gt;
      &lt;br /&gt;
      &lt;input type="submit" id="submit" name="submit" onsubmit="showDetail(wallet01)"&gt;
  
  
  &lt;/form&gt;
  &lt;br&gt;
  &lt;div id="txtHint"&gt;&lt;b&gt;Kit info will be listed here.&lt;/b&gt;&lt;/div&gt;
  
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>and here is my php</p>
  
  <pre><code>&lt;?php
  $q = $_GET['q'];
  
  $con = mysqli_connect('10.1.75.131','markdv','qwerty123','MTNAutomation');
  if (!$con) {
      die('Could not connect: ' . mysqli_error($con));
  }
  
  mysqli_select_db($con,"MTNAutomation");
  $sql="SELECT serialNumber FROM Kit_T WHERE serialNumber = '$q'";
  $result = mysqli_query($con,$sql);
  
  echo "&lt;table border='1'&gt;
  &lt;tr&gt;
  &lt;th&gt;Wallet Number&lt;/th&gt;
  &lt;/tr&gt;";
  
  while($row = mysqli_fetch_array($result)) {
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;" . $row['serialNumber'] . "&lt;/td&gt;";
  
      echo "&lt;/tr&gt;";
  }
  echo "&lt;/table&gt;";
  
  mysqli_close($con);
  ?&gt; 
  </code></pre>