[eluser]CroNiX[/eluser]
Well, you're not returning the total from your function
Code:
public function count_hygiene_factor($name)
{
//query to sum up the scores
//Need to provide an alias for your total in order to retrieve it from the result
$sql = "SELECT SUM(Factor2Score + Factor5Score + Factor6Score + Factor8Score + Factor9Score + Factor12Score) AS `total`
from FactorSurveyScore
where Name = ?";
//2nd parameter for bindings should be an array of data in order that they appear in the query.
$q = $this->db->query($sql, array($name))->row();
if ($q->num_rows() > 0) //check for result
{
return $q->total; //actually return the value
}
else
{
return 0;
}
}