• autocomplete+PHP+MYSQL的实现模糊查询


    1、HTML网页表单部分:

    <input type="text" name="course" id="course" />

    2、JS代码部分:

    <script type="text/javascript" src="jquery.js"></script>
    <script type='text/javascript' src='jquery.autocomplete.js'></script>
    <link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
    
    <script type="text/javascript">
    $().ready(function() {
     $("#course").autocomplete("get_course_list.php", {
       260,
      matchContains: true,
      selectFirst: false
     });
    });
    </script>

    3、PHP 后台部分:

    <?php
    require_once('Connections/bz_conn.php');
    mysql_select_db($database_bz_conn, $bz_conn);
    $q = strtolower($_GET["q"]);
    $sql = "select *  from  bz_user where  ucompany LIKE '%$q%'";
    $rsd = mysql_query($sql);
    while($rs = mysql_fetch_array($rsd)){
    $ucompany = $rs['ucompany'];
    $ucompany=iconv("gb2312","utf-8",$ucompany);  //注意:我的网页、php文件、数据库等 都为GB2312 编码,所以这里转了一下码
     echo "$ucompany ";
    }
    ?>

  • 相关阅读:
    STS 配置tomcat以后,无法访问
    docker
    Java
    STS
    Java
    docker
    sql产生随机时间
    sql产生随机数
    Android 代码自动提示功能
    Activity的跳转与传值
  • 原文地址:https://www.cnblogs.com/yzycoder/p/5262626.html
Copyright © 2020-2023  润新知