I have an AJAX code that posts an ID to a PHP page, a year, and a semester, and at the success function. I console the data in order to see the JSON array but it only shows the JSON array when I don't put the semester into the AND clause of PHP. My code:
AJAX:
$(document).ready(function() {
    $("#semester").change(function() {
        $("#year").change(function() {
            $('.searchBtn').click(function() {
                var id = this.id;
                var year = $("#year option:selected").val();
                var semester = $("#semester option:selected").val();
                console.log(id);
                console.log(semester);
                console.log(year);
                $.ajax({
                    traditional:true,
                    url: "getLoad.php",
                    method: "POST",
                    data:{
                        id:id,
                        semester:semester,
                        year:year
                    },
                    dataType: "JSON",
                    success:function(data){
                        console.log(data);
                        $("#studentLoad").css("display","block");
                       // $("#courseCode").text(data.sem);
                    }
                });
            });
        });
    });
});
PHP:
<?php
require("connect.php");
$query = "SELECT * FROM stud_enrollment AS se JOIN subjectschedule AS s ON se.subjectscheduleid = s.subSchedID JOIN subject AS sub ON sub.subjectID = s.subjectid WHERE se.studentid = {$_POST['id']} AND s.academic_year_start = {$_POST['year']} AND s.semester = {$_POST['semester']}";
$retval = mysqli_query($db, $query);
$data = array();
while($row = mysqli_fetch_assoc($retval)) {
    $data[] = $row;
}
echo json_encode($data);
?>
Removing the semester from the AND clause will allow the data to appear in the console but adding it will do the opposite.
 
     
    