function partSearch() { if ($_POST['typelist'] == '' && $_POST['Make'] == '' && $_POST['Series'] == '' && $_POST['Model'] == '' && $_POST['search'] == '' ) { $data['heading'] = "Browse Parts"; $data['content'] = 'main/part/browse'; $data['message'] = 'Please enter at least one search term'; # load the view template and pass the data to it. $this->Main_model->fillData($data); //$this->load->view('template',$data); } else { if ($_POST['search'] != '') { if ($_POST['comment'] == true) { //TODO: this needs to be done before the other "$this->db->where"s or stuff will go wrong $this->db->from('Part', 'PartDetail'); $this->db->where('Part.ID', 'PartDetail.ID'); /* this->db->[or_]like(column, searchstring); */ $this->db->like('Part.Comment', $_POST['search']); /* Apparently if you don't give an index when assigning some * thing in an array it automatically appends */ //$tmp = 0; $ids[]; foreach ($this->db->get()->result() as $row) { //$ids[$tmp] = $row->ID; //$tmp += 1; $ids[] = $row->ID; } unset ($tmp); } } /* Don't touch these bits, they work */ if ($_POST['typelist'] != '') { $this->db->where('Type', $_POST['typelist']); }if ($_POST['Make'] != '') { $this->db->where('Make', $_POST['Make']); }if ($_POST['Series'] != '') { $this->db->where('Series', $_POST['Series']); }if ($_POST['Model'] != '') { $this->db->where('Model', $_POST['Model']); } /* End Don't touch */ if ($_POST['comment'] == true) { $this->db->where('ID', $ids[]); } if ($_POST['search'] != '') { /* this->db->[or_]like(column, searchstring); */ $this->db->like('make', $_POST['search']); $this->db->or_like('model', $_POST['search']); $this->db->or_like('series', $_POST['search']); } } $data['query'] = $this -> db -> get('PartDetail'); $data['heading'] = "Search Results"; $data['content'] = 'main/searchResults'; $data['message'] = 'You can refine your results further when I add that ability'; # load the view template and pass the data to it. $this->Main_model->fillData($data); //$this->load->view('template',$data); }