function income_reports : model
$this->db->where('tbl_sub_products.sub_product_id',
$this->input->post('product_cat'));
Hi, I am kind of new to codeigniter .Some one can please explain me how we can change this code to grab multiple inputs from the view.
It takes only one value at ones. If we select multiple values it shows as an empty array.
<select name="product_cat" multiple="multiple" size="8">
<?php if (isset($product_cat)) : foreach ($product_cat as $row) : ?> <option value="<?php echo $row->sub_product_id; ?>"> <?php echo $row->sub_product_name; ?> </option> <?php endforeach; ?> <?php endif; ?>
</select>
to
<select name="product_cat[]" multiple="multiple" size="8">
<?php if (isset($product_cat)) : foreach ($product_cat as $row) : ?> <option value="<?php echo $row->sub_product_id; ?>"> <?php echo $row->sub_product_name; ?> </option> <?php endforeach; ?> <?php endif; ?>
</select>
In controller or model, Your Query should be :: $this->db->where_in('tbl_sub_products.sub_product_id',$this->input->post('product_cat')); PS: $this->input->post('product_cat') is an array.
Use Associative Array.
$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
$this->db->where($array);
If you have OR
/AND
associations, then try
$this->db->where( "(loginid = '$username' OR email = '$username') AND (status = 'Active')" );