I'm terribly confused about how I write this function ... it basically clogs the test, and it WORKS for a single user value.
Let's say I need values ββfor the following user: $id = 2... it works! If $id = array(2,3,4,5)not working!
function get_score_a($id){
foreach($this->get_results_a($id,4)->row() as $key=>$a){
if ($a >= 2 && $a <= 4) {
$score_a += 2;
} else if ($a > 4 && $a < 8) {
$score_a += 3;
} else if ($a > 8) {
$score_a += floor($a - 8) * .5;
$score_a += 3;
}
};
return $score_a;
}
function get_results_a($id, $method) {
$select_cols = array(
1 => array('a_1','a_2','a_4'),
2 => array('a_6','a_8','a_11','a_12','a_14'),
3 => array('a_3','a_10'),
4 => array('a_5','a_7','a_9','a_13')
);
return $this->db->select($select_cols[$method])
->where_in('id', $id)
->get('be_survey');
}
This returns a score ... however, if I run multiple identifiers ... it just adds all the numbers, I think ...
Instead, I need this to output individual points for individual users ...
Can you notice that I'm a complete noob! Very cheerful explanations are greatly appreciated. :)
Edit
Please review my code ... how I should have been more clear! Sorry I apologize! In summation, it selects the correct values ββfrom the table based on
, !
Edit
! Codeigniter!