如何基于多个复选框进行搜索

I have a form with checkbox based on which I want to made a search in sql table.

<input name="pc[]" type="checkbox" value="1">I  &nbsp &nbsp &nbsp   
<input name="pc[]" type="checkbox" value="2">II  &nbsp &nbsp &nbsp   
<input name="pc[]" type="checkbox" value="3">III

If checkbox 1 is ticked then the query should be like this

$result=$mysql_query="SELECT * FROM students1 WHERE PartCode IN ('1') "; 

If checkbox 1 and 2 are ticked then the query should be like this

$result=$mysql_query="SELECT * FROM students1 WHERE PartCode IN ('1', '2') "; 

etc.

For that purpose I wrote the following code. But its not working.

$ad = implode ("','",$_POST['pc']); 
$result=mysql_query("SELECT * FROM students1 WHERE PartCode IN ('$ad') "); 

how to edit the code?

Remove the quotes for $ad from the query. Also your implode is not enclosing the values within quotes. So try with the following code:

$ad  = "'" .implode("', '", $_POST['pc']) . "'";   // outputs '1', '2' etc
$result=mysql_query("SELECT * FROM students1 WHERE PartCode IN ($ad) ");
<input name="pc[]" type="checkbox" value="1">I  &nbsp &nbsp &nbsp   
<input name="pc[]" type="checkbox" value="2">II  &nbsp &nbsp &nbsp   
<input name="pc[]" type="checkbox" value="3">III

<script>

jQuery("input[type=checkbox]").click(function(){
        var selectedCheckBoxArray = new Array();
        var n = jQuery("input[type=checkbox]:checked").length;
        if (n > 0){
            jQuery("input[type=checkbox]:checked").each(function(){
                selectedCheckBoxArray.push($(this).val());
            });
            //send check box data value array to server using Ajax

            $.ajax({
                    type: "POST",
                    url: "server_file.php",
                    data: { myCheckboxes:selectedCheckBoxArray },
                    success: function(data){
                        $('#myResponse').html(data);
                    }
            });

        }

    });
</script>