[eluser]Judgestar[/eluser]
Cronix, I am hoping you can help me one more time. I am getting the results array from my count on the webpage, but it shows up as only an array. I did a print_r to debugg the problem and I am seeing the count in the array but it is not displaying correctly. Wondering if you can see where I went wrong.
controller is as you suggested:
Code:
public function survey_results()
{
$name = $this->session->userdata('name');
$data['HygieneCount'] = $this->User_Model->count_hygiene_factor($name);
$this->load->view('factors_survey/survey_results', $data);
}
the model function you suggested did not work, it kept giving me an error when I did
but this ended up working and is showing the array just not what I want to see exactly:
Code:
$sql = "SELECT SUM(Factor2Score + Factor5Score + Factor6Score + Factor8Score + Factor9Score + Factor12Score) AS total
from FactorSurveyScore
where Name = ?";
$query = $this->db->query($sql, $name);
if ($query->num_rows > 0)
{
return $query->result();
}
else
{
return 0;
}
in the view it's a simple p tag and also a print_r to see what's in the array for debug purposes.
Code:
<p>Your Hygiene Factor Score is: <?php echo $HygieneCount; ?> <?php print_r($HygieneCount); ?>
and this is the output on the webpage:
Your Hygiene Factor Score is: Array Array ( [0] => stdClass Object ( [total] => 30 ) )
as you can see the 30 from the questions is there ( and is the correct data) but I am not able to show that data from the array for some reason. What am I missing that is preventing the data from showing correctly?