In `addstudentsession.php`I have a drop down menu below where it contains list of exams and I also have an empty multi select box an empty multi select box:

```
    //FROM VIEW SOURCE:

        <select name="session" id="sessionsDrop">
        <option value="">Please Select</option>
        <option value='20'>EWYGC - 10-01-2013 - 09:00</option>
        <option value='22'>WDFRK - 11-01-2013 - 10:05</option>
        <option value='23'>XJJVS - 12-01-2013 - 10:00</option>
        <option value='21'>YANLO - 11-01-2013 - 09:00</option>
        <option value='24'>YTMVB - 12-01-2013 - 03:00</option>
        </select> </p> 

    //FROM CODE:

    $studentSELECT = "";  
    $studentSELECT .= '<select name="studenttextarea" id="studentselect" size="6">';
    $studentSELECT .= '</select>'; 

//AJAX CODE:

         $(document).ready( function(){

        $('#sessionsDrop').change( function(){
            var search_val = $(this).val();
            $.post("addedstudents.php", 
            {studenttextarea : search_val}, 
            function(data){
   if (data.length>0){ 
     $("#studentselect").html(data); 
   } 
)};

```

Now what is suppose to happen is that when an exam is selected from the drop down menu, an ajax call is activated and it navigates to a separate php page where in that page it runs a query to see how many students are currently in the assessment. If there are no 0 students then it state that there are no students in the assessment, else it will display the alias and names of each student in the exam.

The problem I have though is that if I choose an assessment which I know has students currently in the assessment, it still displays the message that there are no students in the Assessment, instead of actually displaying the list of student's alias and names. My question is why can it list down the students that are in the assessment and instead just keep displaying the message that there are no students?

I know the query is correct as that I have tested the query in phpmyadmin and it works fine. Is the problem in the `addedstudents.php` code below:

```
$session = isset($_POST['session']) ? $_POST['session'] : '';

$studentactive = 1;

$currentstudentqry = "
SELECT
ss.SessionId, st.StudentId, st.StudentAlias, st.StudentForename, st.StudentSurname
FROM
Student_Session ss 
INNER JOIN
Student st ON ss.StudentId = st.StudentId
WHERE
(ss.SessionId = ? and st.Active = ?)
ORDER BY st.StudentAlias
";

$currentstudentstmt=$mysqli->prepare($currentstudentqry);
// You only need to call bind_param once
$currentstudentstmt->bind_param("ii",$session, $studentactive);
// get result and assign variables (prefix with db)

$currentstudentstmt->execute(); 

$currentstudentstmt->bind_result($dbSessionId,$dbStudentId,$dbStudentAlias,$dbStudentForename,$dbStudentSurname);

$currentstudentstmt->store_result();

$studentnum = $currentstudentstmt->num_rows();   

$studentSELECT = "";     

if($studentnum == 0){

$studentSELECT .= "<option disabled='disabled' class='red' value=''>No Students currently in this Assessment</option>"; 

}else{   

while ( $currentstudentstmt->fetch() ) {

$studentSELECT .= sprintf("<option disabled='disabled' value='%s'>%s - %s s</option>", $dbStudentId, $dbStudentAlias, $dbStudentForename, $dbStudentSurname) . PHP_EOL; 
}

}

echo $studentSELECT;

```