Welcome Guest, Not a member yet? Register   Sign In
Codeigniter + JQuery 1.4.2 + autocomplete
#9

[eluser]Nurdin Bekkeldiev[/eluser]
Hi all, I have strange error which I could not solve. The function itself works fine, when I call it by jQuery autocomplete, it doesn't work. In the model I got the list of news titles and then I explode titles in order to list only the words which contain the string that I was searching. Can you help me please.

When I remove this line
Code:
if (strlen(strpos($exs[$t],$terms)) > 0) {
I got the list of the words within the title. But I need only the words which contain only the string that I was searching.

Code:
function search() {
        $return_arr = array();
        //
        $return_arr['response'] = 'false'; //Set default response
        $terms = $this->input->post('search');
        $result = $this->news_model->getManyResult(array('keyword' => $terms));
        if ($result)
        {
            $return_arr['response'] = 'true'; //Set response
            $return_arr['message'] = array(); //Create array
            foreach ($result as $row) :
                $exs = explode(" ", $row->title);
                    for ($t = 0; $t < count($exs); $t++) {
                        if (strlen(strpos($exs[$t],$terms)) > 0) {
                            $return_arr['message'][] = array('label'=> $exs[$t], 'value'=> $exs[$t]); //Add a row to array
                        }
                    }
            endforeach;
        }
        echo json_encode($return_arr);

    }


Messages In This Thread
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 02:17 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 03:16 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 03:42 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 03:46 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 03:50 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-16-2010, 05:41 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 09-17-2010, 04:51 PM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 10-17-2010, 02:06 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 11-08-2010, 03:32 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 11-22-2010, 04:39 PM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 12-07-2010, 09:56 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 12-07-2010, 10:38 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 12-08-2010, 12:48 AM
Codeigniter + JQuery 1.4.2 + autocomplete - by El Forum - 12-08-2010, 02:19 AM



Theme © iAndrew 2016 - Forum software by © MyBB