Скриншот формы
Мой код контроллера:
Код: Выделить всё
class Search extends CI_Controller
{
public function normal()
{
$this->form_validation->set_rules('job_keywords', 'Job Keywords', 'required');
if ($this->form_validation->run() == FALSE) {
$viewdata['main_view'] = 'home';
$this->load->view('layout/main', $viewdata);
} else {
$search_term = $this->input->post('job_keywords');
$location = $this->input->post('job_location');
$type = $this->input->post('job_type');
$searchdata['search_results'] = $this->search_model->default_search($search_term, $location, $type);
$searchdata['main_view'] = 'search_page';
$this->load->view('layout/main', $searchdata);
}
}
}
Код: Выделить всё
public function default_search($search_term, $location="", $type)
{
$searchterm = $search_term;
$this->db->like('job_title', $searchterm);
$this->db->or_like('job_description', $search_term);
$this->db->where('type_id', $type);
if ($location!= "") {
$this->db->like('location_id', $location);
}
$res = $this->db->get('jobs');
if ($res->num_rows() >= 1) {
return $res->result();
} else {
return false;
}
}
Структура таблицы должностей с двумя строками данных
Подробнее здесь: https://stackoverflow.com/questions/369 ... deigniters
Мобильная версия