2017-09-07 11 views
0

사용자 유형이 입력되고 컨트롤러에서 일부 기능을 수행하도록 정의 된 ajax를 호출합니다. 그 입력에 따라 테이블 행을 짧게 나열해야하며, 데이터베이스의 2 또는 3 열과 일치시켜야합니다. 나는이 간단한 PHP 코드를 작업하고있다. ajax를 호출하고 스크립트에서 ajax가 호출하는 다른 페이지의 출력을 표시합니다. 하지만 codeigniter에서 작동해야합니다. 나는 어떻게이 일을 할 수 있을지 모르겠다. 도움이나 조언이 필요하십니까? this is the function that ajax calls on input change. i've tried to convert my simple php working page code into codeigniter. + i'm calling brandlookup1 which is another page then my current page. any syntax error or best practice? for this kind of issues.Ajax, 테이블에서 행을 검색하기위한 입력, 라이브 검색

답변

0

이 작업을 시도해야합니다 :

컨트롤러에서 모델에서

function fetch_brands(){ 
    $search = $this->input->post('query'); 
    $data['record1] = $this->Model_Name->Function_Name($search); 
} 

function Function_Name($search){ 
    $this->load->database(); 
    $search = $this->db->escape_str($search); 
    $sql = 'select * from brand where brand like "%'.$search.'%" OR description like "%'.$search.'%" OR status like "%'.$search.'%"'; 

    $query = $this->db->query($sql); 
    return $query->result(); 
} 
관련 문제