i have a select field named categories[] with multiple select and i written one on change function so on change fuction it will go the controller as an array of id's now what i want is i want to select foods from mysql table with these categories
<select name="categories[]">
<?php
foreach ($category as $c) {
?>
<option value="<?php echo $c->category_id; ?>"><?php echo $c->category_name;?></option>
<?php
}
?>
</select>
controller
public function get_foods(){
$categories = $this->input->post(NULL,true);
$sql = $this->subscription->get_foods($categories);
$result = array(
'result' => $sql
);
echo json_encode($result);
}
and model
public function get_foods($id){
$sql = "SELECT * FROM food_category fc
LEFT JOIN food f ON fc.food_id=f.food_id
WHERE f.food_status = 1 AND
fc.category_id = $id
ORDER BY f.food_id DESC";
$query = $this->db->query($sql);
return $query->result_array();
}
i want to fetch all the foods in these categories, so i think i should have to use some multiple where condition ?