![]() |
Form radio buttons will not validate, need help. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Form radio buttons will not validate, need help. (/showthread.php?tid=51568) Pages:
1
2
|
Form radio buttons will not validate, need help. - El Forum - 05-10-2012 [eluser]CroNiX[/eluser] Depends on how you called it. If you were using this function: Code: public function survey_results() Code: echo $HygieneCount; Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [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() the model function you suggested did not work, it kept giving me an error when I did Code: return $q->total; Code: $sql = "SELECT SUM(Factor2Score + Factor5Score + Factor6Score + Factor8Score + Factor9Score + Factor12Score) AS total 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? Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [eluser]CroNiX[/eluser] Well, you're only returning the result set (which is an array of objects) and not the individual value. What is the output of <?php print_r($HygieneCount); ?> Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [eluser]Judgestar[/eluser] the output is this: Array ( [0] => stdClass Object ( [total] => 30 ) ) Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [eluser]CroNiX[/eluser] Code: if ($query->num_rows() == 1) Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [eluser]Judgestar[/eluser] Awesome ![]() So basically you sent the results of the query to the array and then told the array to return the position with the correct data that was called 'total'? Asking to make sure I understand how that was done, so I can learn. Form radio buttons will not validate, need help. - El Forum - 05-11-2012 [eluser]CroNiX[/eluser] Yep. Probably could have just done: Code: return $query->row()->total; |