Welcome Guest, Not a member yet? Register   Sign In
Form radio buttons will not validate, need help.
#12

[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
Code:
return $q->total;
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: &lt;?php echo $HygieneCount; ?&gt; &lt;?php print_r($HygieneCount); ?&gt;

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?




Messages In This Thread
Form radio buttons will not validate, need help. - by El Forum - 05-09-2012, 08:19 AM
Form radio buttons will not validate, need help. - by El Forum - 05-09-2012, 09:41 AM
Form radio buttons will not validate, need help. - by El Forum - 05-09-2012, 10:10 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 09:53 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:06 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:28 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:33 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:38 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:39 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:41 AM
Form radio buttons will not validate, need help. - by El Forum - 05-10-2012, 10:50 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 07:14 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 09:21 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 09:26 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 09:30 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 09:44 AM
Form radio buttons will not validate, need help. - by El Forum - 05-11-2012, 09:51 AM



Theme © iAndrew 2016 - Forum software by © MyBB