<script>
function showUser(str) {
    if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else { 
        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","getuser.php?q="+str,true);

        xmlhttp.send();
    }
}
</script>
// this is my code

//i want to search using two search fields

my html code is here

<form>
<select name="users" onchange="showUser(this.value)">
  <option value="">Select Class:</option>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
  <option value="4">4</option>
  <option value="1">5</option>
  <option value="2">6</option>
  <option value="3">7</option>
  <option value="4">8</option>
  <option value="1">9</option>
  <option value="2">10</option>
  <option value="3">+1</option>
  <option value="4">+2</option>
  </select>
  <select name="users1" onchange="showUser1(this.value)">
            <option value="">Division</option>
            <option value="A">A</option>
            <option value="B">B</option>
            <option value="C">C</option>
            <option value="D">D</option>
            <option value="E">E</option>
            <option value="F">F</option>
            <option value="G">G</option>
            <option value="H">H</option>
            <option value="I">I</option>
            <option value="J">J</option>
            <option value="K">K</option>
            <option value="L">L</option>
            <option value="M">M</option>
            <option value="N">N</option>
                                                  </select>
</form>
<br>
<div id="txtHint"><b>Person info will be listed here...</b></div>

and my getuser.php is here

<?php
$q = intval($_GET['q']);

$con = mysqli_connect('localhost','root','');
if (!$con) {
    die('Could not connect: ' . mysqli_error($con));
}

mysqli_select_db($con,"shamsu");
$sql="SELECT * FROM schoolentry WHERE classs = ".$q." ";
$result = mysqli_query($con,$sql);

echo "<table>
<tr>

<th>Image</th>
<th>Student Name</th>
<th>Admission No</th>
<th>Parent Name</th>
<th>Classs</th>
<th>Division</th>
<th>Address1</th>
<th>Address2</th>
<th>Address3</th>
<th>Address4</th>
<th>Pincode</th>
<th>Phone No</th>
<th>DOB</th>
<th>Adhar No</th>
<th>Blood Group</th>
<th>Mobile No</th>
<th>Edit</th>
<th>Delete</th>


</tr>";

while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['image'] . "</td>";

    echo "<td>" . $row['student_name'] . "</td>";
    echo "<td>" . $row['admission_no'] . "</td>";
    echo "<td>" . $row['parent_name'] . "</td>";
    echo "<td>" . $row['classs'] . "</td>";
    echo "<td>" . $row['division'] . "</td>";
    echo "<td>" . $row['p_address'] . "</td>";
    echo "<td>" . $row['p_address1'] . "</td>";
    echo "<td>" . $row['p_address2'] . "</td>";
    echo "<td>" . $row['p_address3'] . "</td>";
    echo "<td>" . $row['p_address4'] . "</td>";
    echo "<td>" . $row['p_address5'] . "</td>";
    echo "<td>" . $row['dob'] . "</td>";
    echo "<td>" . $row['adhar_no'] . "</td>";
    echo "<td>" . $row['blood_group'] . "</td>";
    echo "<td>" . $row['mobile_no'] . "</td>";

    echo "</tr>";
}

echo "</table>";
mysqli_close($con);
?>


</body>
</html>

//$sql="SELECT * FROM schoolentry WHERE classs = ".$q." "; here i want to search one more field as division=".$q."; like this but iam not getting anything while i wrote like this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.