如何从MySQL获取数据作为数组并根据PHP中的下拉选择动态填充文本字段

I have two categories of Job Applicants in my database: graduates and artisans. I am trying to fetch their emails separately base on the category being selected from the drop down menu.

My objective is to fetch all the emails as an array and populate them into a text field.

for clarity, here is my HTML code:

<div class="form-group">
<div class="form-line">
<select class="form-control smode" name="smode" id="smode" >
<option value="">select Job Seekers</option>
<option value="G">Graduates Only</option>
<option value="A">Artisans Only</option>
</select>
</div>
</div>

<div class="form-group">
<label>Email List</label>
<div class="form-item">
<input type="text" name="email_list" class="form-control" /><!--Field to populate--!>
</div>                                 
</div> 

Js

$('#smode').change(function(){
var packages = $(this).val();
$.ajax({
   type:'POST',
   data:{packages:packages},
   url:'get_email.php',
   success:function(data){
       $('#email_list').val(data);
   } 

});

get_email.php

if (isset($_POST['packages'])) {
    $g =  $_POST['packages'];
    $qry = "select * from jobseeker WHERE confirm_no LIKE '$g'";
    $rec = mysqli_query($mysqli, $qry);
    if (mysqli_num_rows($rec) > 0) {

        $res = mysqli_fetch_array($rec);

        foreach ($res as $rs) {
            $emailArr[] = stripslashes(($rs["mails"]));
        }

        $emails = implode(";", $emailArr);

        echo $emails;

    }
}

Can someone please point me to the right direction.

I'm not a JQuery guru, but I know that Javascript doesn't care for single quotes. Is JQuery similar? (Sorry, I can't add comments yet)