Php 用于多表单下拉列表的单个jquery自动完成
如何在多表单下拉列表中使用单个jquery自动完成 这是我的查看页面(页眉): 模型页:Php 用于多表单下拉列表的单个jquery自动完成,php,jquery,codeigniter,Php,Jquery,Codeigniter,如何在多表单下拉列表中使用单个jquery自动完成 这是我的查看页面(页眉): 模型页: 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_ro
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);
}
}
如何实现可用于多个条件的单个搜索词?提前感谢各位。这不会扩大规模;随着数据库表的增长,此实现将变得非常缓慢。您需要做的是使用索引引擎来允许 MySQL不允许对InnoDB表进行全文搜索(实际上,它刚刚发布了最新版本,但仍处于初级阶段)。研究使用,或 浏览StackOverflow以找到最适合您的引擎-过去有很多关于此问题的有用问题。希望这能让你走上正确的道路
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);
}
}