php - jquery自动完成标签问题

标签 php jquery mysql ajax autocomplete

enter image description here

当输入 1 个字符时,它显示空白,标签在自动完成中丢失。我如何设置自动完成的标签。但是值(value)观来了。 这是带有输入类型文本的表单域。

<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”,响应以数组形式出现。我想显示用户的照片和姓名,我该怎么做...?

这是我获取详细信息的脚本:

/*Search Student starts here*/
$(document).on("focus keyup", "input.searchStudent", function (event) {
    $(this).autocomplete({
        source: 'gdcontroller.php?action=search',
        select: function (event, ui) {
            event.preventDefault();
            this.value = ui.item.label;
        },
        focus: function (event, ui) {
            event.preventDefault();
            this.value = ui.item.label;
        }

    });
});
/*Search Student ends here*/

这是我的 Controller ,我在这里搜索名为“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;
}

最佳答案

试试这个函数 mysql_real_escape_string()

关于php - jquery自动完成标签问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40928016/

相关文章:

Javascript 函数在 Firefox 新版本中无法运行

javascript - 将 appendTo 动态行值传递给 Bootstrap 模式

php - Nginx,PHP-FPM,PHP Module and MySQL Implementation is possible in Kubernetes

MySQL\join 2表product和image表

php - 如何在 php 中调用 protected 方法?

php - 如何将输入时间的值插入到数据库表中?

php - 从 jQuery ajax 调用复制数组

php - 如何同时对多个 PHP 文件执行错误检查?

jquery - 日期选择器设置为今天的日期并禁用周末

mysql - 有没有办法从 Amazon Redshift 进行 SQL 转储