I am currently facing an issue where I receive data in a function from my controller, and inside my model function, I need to retrieve results using a query with a dynamic value of channel. The channel ID will be coming from each checkbox on my HTML view. When I check CHECKBOX 1, it retrieves the data successfully. However, for the second checkbox, it does not return anything. I want to iterate through the query and save the results in the final query. P.S. I am a newbie in CI framework.
function get_data() {
$serial = $this->input->post('serial');
$chanel = $this->input->post('channel_id');
$fi=explode(",", $chanel);
$conditiondata=count($fi);
$arr =array();
for($i=0; $i<$conditiondata; $i++) {
if($i==0) {
$query = $this->db->query("SELECT * FROM `channels` WHERE `serial_id` = '$serial' AND `channel_name` = '$fi[$i]'");
if ($query->num_rows() > 0) {
$arr[$i] = $query->result();
} else {
return false;
}
} else {
return false;
}
}
var_dump($arr);
return $arr;
}