I have problems with where CodeIgniter on the query, which I want to find the data between the two parameters. like the example below.
Controllers
public function search_genus() {
$data = array(
'find_kebun' => $this->my_model->find(),
'content' =>'my_view'
);
$this->load->view('layout/wrapper', $data);
}
Models
public function find() {
$search = $this->input->post('param');
$A = "1 - 10";
$B = "11- 15";
if ($search = $A ) {
$query = $this->db->select('*')
->from('my_tables')
->where('genus', 1 > 10)
->get();
return $query->result();
}else if ($search = $B ) {
$query = $this->db->select('*')
->from('my_tables')
->where('genus', 11 > 15)
->get();
return $query->result();
}
}
Views
<form action="<?php echo base_url(); ?>/search_genus" method="post" enctype="multipart/form-data">
<select name="param">
<option value="A">1 - 10</option>
<option value="B">11 - 15</option>
</select>
<button class="btn btn-default" type="submit">
</form>
after I run error at where how to solve?
Try this - Controller:
public function search_genus() {
$search = $this->input->post('param');
$data = array(
'find_kebun' => $this->my_model->find($search ),
'content' =>'my_view'
);
$this->load->view('layout/wrapper', $data);
}
And Model
public function find($search) {
$A = "1 - 10";
$B = "11- 15";
if ($search == "A" ) {
$query = $this->db->select('*')
->from('my_tables')
->where('genus', 1 > 10)
->get();
return $query->result();
}else if ($search == "B" ) {
$query = $this->db->select('*')
->from('my_tables')
->where('genus', 11 > 15)
->get();
return $query->result();
}