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
";
}
?>