I have an id array in my controller that has checkbox input in a form in views. $toppings = $this->input->get('topping');
Array
(
[0] => 1
[1] => 3
[2] => 4
)
I'm trying to get the information relevant to each id in the array from the database.
$toppings = $this->input->get('topping');
foreach ($toppings as $topping ) {
$id = $topping;
$toppinglist = $this->toppingmodel->find_topping($id);
echo'<pre>'; print_r($toppinglist); die();
}
Model Class -
function find_topping($id)
{
$query = $this->db->get_where('Topping', array('id' => $id));
return $query->row_array(); }
}
The output array i'm getting is only the data for the first id
Array
(
[id] => 1
[slug] => mushroom
[toppingName] => Mushrooms
[price] => 50.00
)
How can i get all the data relevant to each id in an array. (nested array) Thank you.
$this->db->where_in('Topping', $toppings);