title: AJAX Help needed
body: <p>I've recently stumbled upon a small issue. Basically I'm trying to give my users the ability to search thru a certain category on my site, but the search is done via AJAX and will not reload the page, simply the content that is being searched through.</p>
  
  <p>The following codes is what I came up with so far, but the only time where it will change something is when there will be no value in the textbox, other than that the content isnt being updated (I checked the PHP file manually and there is no erros &amp; with HTTP Direct addon for Firefox I made sure the call to my php file is made)</p>
  
  <p>My code:</p>
  
  <p>category.php:</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  function showCat(str, cat)
  {
  if (str=="")
    {
    document.getElementById("showCategory").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("showCategory").innerHTML=xmlhttp.responseText;
      }
    }
    url="../cat_search.php?q="+str+"&amp;cat="+cat
  
  xmlhttp.open("GET",url,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  &lt;input type="text" name="showCat" onkeyup="showCat(this.value, &lt;?=$id?&gt;)" style="width: 140px;" /&gt;
  
      &lt;div id="showCategory"&gt;
       ## Stuff is being listed here on the load of the page &amp; then should be updated with Ajax
  
     &lt;/div&gt;
  </code></pre>
  
  <p>cat_search.php:</p>
  
  <pre><code>&lt;?php
  include("config.php");
  include("global.php");
  
  $q=$_GET["q"];
  $cat=$_GET["cat"];
  
  $search = $q;
  $q = "%".$q."%";
  
  $sql="SELECT * FROM games WHERE title like '$q' AND category = '$cat'";
  $result = mysql_query($sql);
  
  if(mysql_num_rows($result) == 0) {
  echo "&lt;center&gt;&lt;div class=\"redbox\" style=\"width: 110px;\"&gt;No match&lt;/div&gt;&lt;/center&gt;";
  }
  
  while($row = mysql_fetch_array($result)) {
  echo '......';
  } ?&gt;
  </code></pre>
  
  <p>The $id is the actual category ID.</p>
  
  <p>Let me know if you would have the slighest idea of what my problem could be, I use almost the same exact code for another type of search and it works like a charm.</p>
  
  <p>Thanks you!</p>