I have multiple ids in my $temp
like(7,8,9) and I want to compare there ids in my where condition like $this->db->where_in('c.mr_no',$temp);
but it compare only first id
I am trying like this:
Controller:
public function printCollectionRecPage() { $this->load->view('template/header'); $this->load->view('template/sidebar'); $temp =($_GET['id']); $data = array(); $data['collnR'] = $this->PayRecAllModel->printCollectionRecPage($temp); $this->load->view('crossing/payment_rec_allocation/printCollectionRecovery',$data); $this->load->view('template/footer'); }
Model:
public function printCollectionRecPage($temp) { $this->db->select('c.*,payment_rec_allocn.*'); $this->db->from('crossing_cash_memo c'); $this->db->join('payment_rec_allocn', 'payment_rec_allocn.mr_no = c.mr_no'); $this->db->where('c.total !=','0'); $this->db->where('c.mr_no',$temp); $query = $this->db->get(); return $query->result(); }
I want to compare all 3 ids in where condition.
Advertisement
Answer
I think you are receiving an string from $_GET and hence the comparisions are not working as expected.
Change this
$this->db->where('c.mr_no',$temp);
to
$temp = explode(",", $temp); $this->db->where_in('c.mr_no',$temp);
and then try. Where_in excepts the parameter to be an array.