Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php jquery自动完成响应以数组形式出现我如何调用两个字段,如name和photo_Php_Html_Arrays_Ajax - Fatal编程技术网

Php jquery自动完成响应以数组形式出现我如何调用两个字段,如name和photo

Php jquery自动完成响应以数组形式出现我如何调用两个字段,如name和photo,php,html,arrays,ajax,Php,Html,Arrays,Ajax,这是具有输入类型文本的表单字段 <span> <img src="images/author2.jpg" width="50" /> //in Database i have profilepic/userimage.jpg and the image shown in above is a static image. <input class="searchStudent" type="text" autocomplete="off"> </spa

这是具有输入类型文本的表单字段

<span>
<img  src="images/author2.jpg" width="50" />  //in Database i have profilepic/userimage.jpg and the image shown in above is a static image.
<input class="searchStudent" type="text" autocomplete="off">
</span>
这是我的控制器,我正在搜索名为“A”的可用学生 并获取他们的详细信息:

if($_GET['action']=="search" && $_GET['term']!='')
{
    $keysearch = $_GET['term'];
    $studentValue = trim($_GET['studentname']);

    $studentsQuery =$conn->query('select s.student_pid,i.email,s.student_email,s.student_fname,s.student_lname,s.profile_pic from r_job_invitations i 
    LEFT JOIN tbl_students s ON i.email = s.student_email where i.id_job =54 and accounttype = 1 and inv_res = 1 and student_fname LIKE "'.$keysearch.'%" OR student_lname LIKE "'.$keysearch.'%" ')or die(mysqli_error());

    $studentData = array();
    while($student = $studentsQuery->fetch_assoc()){
        $studentData[]= $student;
    }
    echo json_encode($studentData);
    exit;
}

$(文档).on(“焦点键控”,“输入.搜索学生”,函数(事件){
$(此)。自动完成({
来源:“gdcontroller.php?action=search”,
选择:功能(事件、用户界面){
event.preventDefault();
//我在这里遇到了麻烦,连名字都不知道了:
student.student\u fname.value=ui.item.student.student\u fname;
$(“#光容器”)。附加(“”);
},
焦点:功能(事件、用户界面){
event.preventDefault();
this.value=ui.item.label;
}    
});
});

$(文档).on(“焦点键控”,“输入.搜索学生”,函数(事件){
$(此)。自动完成({
来源:“gdcontroller.php?action=search”,
选择:功能(事件、用户界面){
event.preventDefault();
//我在这里遇到了麻烦,连名字都不知道了:
student.student\u fname.value=ui.item.student.student\u fname;
$(“#光容器”)。附加(“”);
},
焦点:功能(事件、用户界面){
event.preventDefault();
this.value=ui.item.label;
}    
});
});

即使我没有得到名字,但当在控制器中只得到名字时,我也只能得到名字。通过替换this
this.value=ui.item.label添加到您的
$(“#photoContainer”)。当输入1个字符时,其显示为空,自动完成中缺少标签。如何设置自动完成标签。但值正在到来。即使我并没有得到名字,但当在控制器中获取唯一的名称时,我也能得到唯一的名称。通过替换this
this.value=ui.item.label添加到您的
$(“#photoContainer”)。当输入1个字符时,其显示为空,自动完成中缺少标签。如何设置自动完成标签。但价值观正在到来。
if($_GET['action']=="search" && $_GET['term']!='')
{
    $keysearch = $_GET['term'];
    $studentValue = trim($_GET['studentname']);

    $studentsQuery =$conn->query('select s.student_pid,i.email,s.student_email,s.student_fname,s.student_lname,s.profile_pic from r_job_invitations i 
    LEFT JOIN tbl_students s ON i.email = s.student_email where i.id_job =54 and accounttype = 1 and inv_res = 1 and student_fname LIKE "'.$keysearch.'%" OR student_lname LIKE "'.$keysearch.'%" ')or die(mysqli_error());

    $studentData = array();
    while($student = $studentsQuery->fetch_assoc()){
        $studentData[]= $student;
    }
    echo json_encode($studentData);
    exit;
}
<div id="photoContainer"></div>

$(document).on("focus keyup", "input.searchStudent", function(event) {
    $(this).autocomplete({
        source: 'gdcontroller.php?action=search',
        select: function (event, ui) {
            event.preventDefault();
            //I'm having trouble here; even name is not coming:
            student.student_fname.value = ui.item.student.student_fname;
            $("#photoContainer").append('<img src="' + ui.item.student.profile_pic + '">'); 
        },
        focus: function(event, ui) {
            event.preventDefault();
            this.value = ui.item.label;
        }    
    });
});