0

我的数据库表中有大约 700 个产品列表。

我正在使用引导程序的令牌字段进行自动完成,我必须在搜索文本框中使用自动完成。

我收到语法错误:

SyntaxError: missing ] after element list

...B'、'Lino Perros 男士皮革钱包 - 粉色'、'Lenovo A269i'、'Lenovo S660 - Tita**

在控制台中。

<?php $t = $this->general_model->auto_complete_sug(); ?>

$( document ).ready(function() {
    $('#tokenfield-2').tokenfield({
        autocomplete: {
            source: <?=$t?>,
            delay : 100
        },
        limit: 1,
        minLength: 1,
        showAutocompleteOnFocus: true
    });
});
<input type="text" class="span2" name="search" id="tokenfield-2" placeholder="Search...">

In my model: I have created this functions:


public function auto_complete_sug()
	{
		$data = $this->auto_complete_token_fun();

		$data1 = explode(',', $data);
		$data1 = array_unique($data1);
		foreach ($data1 as $value1) {
			$temparr[] = $value1;
		}
		$str = '[';
		$c = count($temparr);
		$counter = 0;
		foreach ($temparr as $val) {
			$counter++;
			$str .= "'".$val."'";
			if($counter < $c){
				$str .= ",";
			}
		}
		$str .= ']';
		return $str;
	}
                              
                              
public function auto_complete_token_fun()
	{
		// $this->db->query("SET GLOBAL group_concat_max_len = 10000000");
		$q = $this->db->query("SELECT GROUP_CONCAT( sub_category_name ) AS scname
			FROM `tbl_subcategory` WHERE status = 'Active' ");
		if($q->num_rows() > 0)
		{
			$d = $q->row_array();
			return $d['scname'];
		}
		else
		{
			return '';
		}
	}

请帮忙!!

4

0 回答 0