多个表单下拉单jquery自动完成
问题描述:
我怎样才能使用单个jQuery自动完成多表单下拉?多个表单下拉单jquery自动完成
这里是我的看法页(头):
$("#full_name").autocomplete({
source: "<?php echo site_url('autocomplete/get_names');?>"
});
$("#department").autocomplete({
source: "<?php echo site_url('autocomplete/get_dept');?>"
});
*** and other like these for subjects, zip and country.
控制器页:
public function get_names(){
$this->load->model('autocomplete_model');
if (isset($_GET['term'])){
$q = strtolower($_GET['term']);
$this->autocomplete_model->get_fullnames($q);
}
}
*** and other functions...
模式页:
function get_fullnames($q)
{
$match = $q;
$this->db->select('full_name');
$this->db->like('full_name', $match,'after');
$query = $this->db->get('employee_list');
if($query->num_rows > 0){
foreach ($query->result_array() as $row){
$row_set[] = htmlentities(stripslashes($row['full_name']));
}
echo json_encode($row_set);
}
}
我如何可以实现一个单一的搜索项,可以用于多个标准?
谢谢你们提前..
答
这是不按比例;随着数据库表的增长,这个实现将变得非常缓慢。你需要做的是使用索引引擎来允许Full Text Searching。
MySQL不允许在InnoDB表上进行全文搜索(实际上,它只是在最新版本中发布,但它仍处于起步阶段)。看看使用Elastic Search,Sphinx或Solr。
打开StackOverflow以找到最适合您的引擎 - 过去曾询问过有关此问题的许多有用问题。希望能让你走上正确的道路。
感谢您的信息.. – swordfish 2013-02-10 19:48:45