Q:

How to get the value of the dropdown menu as a SQL query in php file and Display the query result on table? 

i have a table that contains all the records of my db but i want to filter it using 2 dropdown list.  like i have 4 columns on my table ID, Name, Subject and Section iwant to filter the results using a dropdown list for Subject and Section
those 2 dropdown list are connected to db section_ubject, and i use php - sql to populate the dropdown list
next is i have a filter button, if i click on it the table records will be filtered according to the selected dropdown record. 
the thing is i dont know how to run the query on the other php file where i declare the query as a function. 

function AllList() {
    $qry = "SELECT * 
        FROM student_subject WHERE SUBJECT = DROPDOWN1 AND SECTION = DROPDOWN2
        ORDER BY `Section` DESC,Name ASC";
        return $this->select($qry);
}

i just dont know how will i get the value of those dropdown lists :( 
hope somebody would help me :( thanks in advance. 

A:

you can use jquery ajax to get values of dropdowns and send them to php script.  For example;
    <select name="dropdown1">
    <option>Value 1</option>
    <option>Value 2</option>
    <option>Value 3</option>
    </select>
    <select name="dropdown2">
    <option>Value 4</option>
    <option>Value 5</option>
    <option>Value 6</option>
    </select>
    <a href="javascript:;" id="filter_btn">Filter</a>
    <script>
    $(function(){
        $("a#filter_btn").click(function(){
            var dropdown1 = $("select[name=dropdown1] :selected").val();
            var dropdown2 = $("select[name=dropdown2] :selected").val();    

            if(dropdown1 ! = '' && dropdown2 ! = ''){
                $.ajax({
                type : "POST",
                url : "filter.php",
                data : "dropdown1="+dropdown1+"&dropdown2="+dropdown2,
                    success: function(response){
                        alert(response);
                    }
                  });
              }
           });
       });
       </script>

 and in php you can get them like;
        <? php
        $drop1 = $_POST["dropdown1"];
        $drop2 = $_POST["dropdown2"];
        ? >

