Codigniter grouping in views |
Hello Codeigniter Community.
I am just new to Codeigniter. And I am facing a small challenge now. Would you help me solve this? Here is my problem: I am making a questionaire system. The user should be able to create a questionaire, add questions and add choices to it. The question will go to "question" table and the choices will go to the "choices" table. I did this by saving the question first, get the inserted id, then insert each choice. Now, I want to retrieve all the questions connected to a questionaire. I did this by joining the question table and the choices table. I want my questions to look like this: EXAMPLE ------------------------------- 1. How's your mama? [] Happy [] Not Happy ------------------------------------- Now my question is: How can I display the question once, then display all the choices below? Like the provided example above. Here's what I have tried so far: Code: public function select_question_choices($survey_id) Then I call that method in a controller. Then I pass the result into a view. Now, when I do a foreach loop, the result I get, compared to the given example above: How's your mama [] Happy How's your mama [] Not Happy It shows the quesiton as many times as the choices. So if I have 5 choices, it will also display the question 5 times. Would you help me with this? I hope I explained myself well. Thanks in advance. Any help/suggestion would be much appreciated. |
Messages In This Thread |
Codigniter grouping in views - by danangeloalcanar - 10-28-2017, 07:34 AM
RE: Codigniter grouping in views - by PaulD - 10-28-2017, 07:56 AM
RE: Codigniter grouping in views - by danangeloalcanar - 10-28-2017, 07:11 PM
RE: Codigniter grouping in views - by PaulD - 10-29-2017, 04:27 AM
RE: Codigniter grouping in views - by danangeloalcanar - 10-29-2017, 08:54 PM
|