在Codeigniter中进行过滤和搜索 [英] Filtering and searching in codeigniter

查看:40
本文介绍了在Codeigniter中进行过滤和搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在codeigniter中进行过滤 searching ,但不知道!该怎么做?

I am doing a filtering and searching in codeigniter but no idea! how to do that?

但是我尽力而为,但失败了!

but i try my best but fail!!!

在这里,我显示了成功的ajax显示的列表

here i show the list which is shown by ajax that sucess

我的数据库

我的控制器是

  public function get_quick_search() 
{
        $sepcli= $this->input->post('spec');
        $distct= $this->input->post('dist');
        $locat= $this->input->post('locat');
         $data['list'] = $this->Doctor_model->search_listing();
        $data['quck_search'] = $this->search_model->get_quick_list($sepcli,$distct,$locat);
        $data['get_specs'] = $this->specialisation_model->get_specialisation();
        $this->load->helper(array('form', 'url'));
        $this->load->view('customer/header');
        $this->load->view('customer/side_view',$data);
        $this->load->view('customer/quick_search',$data);
        $this->load->view('customer/footer');
}

喜欢我的模型

 public  function get_quick_list($locat,$distct,$sepcli)  
{  
    $this->db->select('*');    
        $this->db->from('tbl_doctor');  
        $this->db->join("tbl_specialisation", "tbl_specialisation.spec_id = tbl_doctor.spec_id",'left');

        $this->db->where("(district LIKE '$distct' AND place LIKE '$locat' AND spec_specialise LIKE '$sepcli')");

    $query=$this->db->get()->result_array(); 

 
          return $query;
}

在没有错误的情况下显示返回查询为 NULL 在此显示为(array(0){})

HERE NO ERROR SHOW BUT THE RETURN QUERY IS NULL SHOW LIKE THIS (array(0) { })

推荐答案

您可以这样尝试,您的控制器功能代码

you might try like this ,Your Controller function code

public function get_quick_search()
{
        $s_data['sepcli'] = $this->input->post('spec');
        $s_data['distct'] = $this->input->post('dist');
        $s_data['locat']  = $this->input->post('locat');


        $data['quck_search'] = $this->search_model->get_quick_list($s_data);
        $data['get_specs'] = $this->specialisation_model->get_specialisation();
        $this->load->helper(array('form', 'url'));
        $this->load->view('customer/header');
        $this->load->view('customer/side_view',$data);
        $this->load->view('customer/quick_search',$data);

        $this->load->view('customer/footer');
}

您的模型功能代码

public  function get_quick_list($s_data)  
{  
    $this->db->select('td.*, ts.*')
    $this->db->from('tbl_doctor as td');    
    $this->db->join('tbl_specialisation as ts', 'ts.spec_id = td.spec_id','left');

    if($s_data['sepcli'] !="")
       $this->db->like('ts.spec_specialise',$s_data['sepcli'],'both');
    if($s_data['distct'] !="")
       $this->db->like('td.district',$s_data['distct'],'both');
    if($s_data['locat'] !="")
       $this->db->like('td.place', $s_data['locat'], 'both');

    $query=$this->db->get()->result_array(); 
    return $query;
}

确保它会有所帮助,您应该尝试一下!!!

sure it will helps , you should try it !!!

这篇关于在Codeigniter中进行过滤和搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆