Help PHP + AJAX

Hi i am alan
I’m new using PHP + AJAX

this is code


<html>
<head><title>Master Desain</title>
<script>
function showHint(str)
{
if (str.length==0)
  {
  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 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getbahan.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

<p><b><span class="style17">Ketikan Nama Bahan : </span></b>
  <input type="text" onKeyUp="showHint(this.value)" size="20" />
</p>
<p><span class="style17">Suggestions:

Please repost your code and use code syntax highlight function of the editor.

this is index.php

<html>
<head><title>Master Desain</title>
<style type="text/css">
.style17 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; }
.style18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; font-style: italic; }
</style>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
function showHint(str)
{
if (str.length==0)
  {
    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 && xmlhttp.status==200)
      {
      document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open("GET","getbahan.php?q="+str,true);
  xmlhttp.send();
  }
</script>
</head>
<body>

<p><b><span class="style17">Ketikan Nama Bahan : </span></b>
  <input name="bahan" type="text" class="style17" id="bahan" onKeyUp="showHint(this.value)" size="20" maxlength="15" />
</p>
<p><span class="style17">Suggestions:</span> <span id="txtHint"> </span></p>

</body>
</html>

this is getbahan.php

<html>
<head><title>Master Desain</title>
<style type="text/css">
.style17 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; }
.style18 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; font-style: italic; }
</style>

<?php

// session_start();
require_once("./Connections/condesain.php");
mysql_select_db("$dbName") or die("Could find table ".mysql_error());

$bhn=$_GET["q"];

$sql = mysql_query("SELECT * FROM desain-a WHERE bahan = '$bhn'");

    $numrows = mysql_num_rows($sql);
  
    echo "<table border='1'>
    <tr>
    <th>ID</th>
    <th>Kode</th>
    <th>Bahan</th>
    <th>Sub</th>
    <th>Lebar</th>
    <th>Pcs</th>
    <th>Stock</th>
    <th>Gambar</th>
    </tr>";
      if ($numrows !=0)
        {
          while($row = mysql_fetch_array($sql))
            {
              echo "<tr>";
              echo "<td>" . $row['id'] . "</td>";
              echo "<td>" . $row['kode'] . "</td>";
              echo "<td>" . $row['bahan'] . "</td>";
              echo "<td>" . $row['sgrp1'] . "</td>";
              echo "<td>" . $row['grp1'] . "</td>";
              echo "<td>" . $row['pcs'] . "</td>";
              echo "<td>" . $row['stock'] . "</td>";
              echo "<td>" .$row[$image['gambar']]. "</td>";
              echo "</tr>";
            }
          echo "</table>";
        }
      else
        echo " Data Tidak ditemukan.";
?>
</head>
</html>

Welcome to the SP forums.

I think you forgot to post your question?

question is i want to show data from table when typing a letter into text box