Welcome Guest, Not a member yet? Register   Sign In
Setting radio button values from database for edit form
#1

[eluser]barrysampson[/eluser]
Hi,

I'm steadily plodding on with my first CI project, and have hit another little problem that has me stumped.

User are asked to complete a form which has 30 questions, for which they have to select one of four answers. I have this working just fine, and I'm using serialize() to store the data in the db. I can get the data back out in the right format using unserialize() but I can't work out how to repopulate the edit form using the values I've pulled from the db.

I won't post the whole form here, but here's the code I'm using in my submit form to record the answer to 1 of the 30 questions.

I'm using a copy of that form to create my edit form but I'm not sure what I need to do to set the radio button values using the the values from the db.

Code:
<tr align="center">
            <td> </td>
            <td>
                &lt;?php
                $selection = array(
                    'name' => 'a1',
                    'id' => 'a1',
                    'value' => 0, //None
                    'checked' => FALSE
                    );
                echo form_radio($selection) ."</p>";
                ?&gt;
            </td>
            <td>
                &lt;?php
                $selection = array(
                    'name' => 'a1',
                    'id' => 'a1',
                    'value' => 1, //Basic
                    'checked' => FALSE
                    );
                echo form_radio($selection) ."</p>";
                ?&gt;
            </td>
            <td>
                &lt;?php
                $selection = array(
                    'name' => 'a1',
                    'id' => 'a1',
                    'value' => 2,  //Intermediate
                    'checked' => FALSE
                    );
                echo form_radio($selection) ."</p>";
                ?&gt;
            </td>
            <td>
                &lt;?php
                $selection = array(
                    'name' => 'a1',
                    'id' => 'a1',
                    'value' => 3, //Advanced
                    'checked' => FALSE
                    );
                echo form_radio($selection) ."</p>";
                ?&gt;
            </td>
        </tr>

Thanks for any help you can offer.


Messages In This Thread
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 08:05 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 08:31 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 08:42 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 09:09 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 09:21 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 09:26 AM
Setting radio button values from database for edit form - by El Forum - 06-12-2009, 09:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB