CodeIgniter Forums
Search feature displays all data from database? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Search feature displays all data from database? (/thread-65743.html)



Search feature displays all data from database? - theromie - 07-18-2016

This is my index.php view file
<form class="form-inline" role="form" id="SJob" action="<?=site_url('search');?>">
        <div class="col-md-6 col-md-offset-3 input-group">
                <input type="text" id="searchjob" name="JSearch" class="input-job form-control"  required="required">
                <div class="input-group-btn">
                        <button class="btn btn-green" type="submit"><i class="fa fa-search"></i></button>
                </div>
         </div>
</form>


This is my model.php
public function get_SearchJobs($match){
            $data = array();
            $match = $this->input->post('JSearch');
            $this->db->like('JTitle', $match);
            $this->db->or_like('Skills', $match);
            $this->db->or_like('JLocation', $match);
            $query = $this->db->get('jobs');           
            
            if($query->num_rows() > 0)
                foreach ($query->result() as $row) {
                    $data[] = $row;
                } 
            return $data;        
        }


This is my controller
public function search(){        
       $data = array();
       $match = $this->input->get('match');                
   $data['result'] = $this->mymodel->get_SearchJobs($match);    
   $this->load->view('search',$data);      
   }