如何在codeigniter中创建搜索功能

时间:2015-08-22 08:04:08

标签: php html5 codeigniter

我想创建简单的搜索功能。我举了一些例子。但我无法得到结果。请帮我。

//查看页面

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: Max redirects exceeded.
    at ClientRequest.cb (/var/parsing/node_modules/follow-redirects/create.js:55:19)
    at ClientRequest.g (events.js:199:16)
    at ClientRequest.emit (events.js:107:17)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:426:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:111:23)
    at Socket.socketOnData (_http_client.js:317:20)
    at Socket.emit (events.js:107:17)
    at readableAddChunk (_stream_readable.js:163:16)
    at Socket.Readable.push (_stream_readable.js:126:10)
    at TCP.onread (net.js:538:20)

//控制器

<form class="navbar-form" role="search" action=" {{ base_url }}search/search_keyword" method = "post">
    <div class="input-group">
        <input type="text" class="form-control" placeholder="Search" name = "keyword"size="15px; ">
        <div class="input-group-btn">
            <button class="btn btn-default " type="submit" value = "Search"><i class="glyphicon glyphicon-search"></i></button>
        </div>
    </div>
</form>

}

//模型

function search_keyword()
{
    $keyword    =   $this->input->post('keyword');
    $data['results']    =   $this->mymodel->search($keyword);
    $this->twig->display('result_view.php',$this->data);
    //$this->load->view('result_view.php',$data);
}

2 个答案:

答案 0 :(得分:2)

更改

 $this->twig->display('result_view.php',$this->data);

 $this->load->view('result_view.php',$data);

答案 1 :(得分:1)

使用此功能

function search_keyword()
{
    $keyword=$this->input->post('keyword');
    $data['results']=$this->mymodel->search($keyword);
    $this->twig->display('result_view.php',$data);
}