Reputation: 356
I am using codeigniter with php. I want to get values from database table by comparing a column. The problem is the value coming from html code to compare with column is checkbox value and array. I want something like it, HTML
<input type="checkbox" name="car[]" value="Audi">Audi<br>
<input type="checkbox" name="car[]" value="BMW">BMW<br>
<input type="checkbox" name="car[]" value="Ford">Ford<br>
and code in codeigniter model is
$this->db->where('car_name ==', $car[]);
$this->db->get('cars');
Upvotes: 0
Views: 2626
Reputation: 5444
Try this...
Generates a WHERE field IN ('item', 'item') SQL query
$names = array('Frank', 'Todd', 'James');
$this->db->where_in('username', $names);
// Produces: WHERE username IN ('Frank', 'Todd', 'James')
Ref:https://ellislab.com/codeigniter/user-guide/database/active_record.html
Upvotes: 1